使用 Java 与 Python 的 Selenium Webdriver
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13960897/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Selenium Webdriver with Java vs. Python
提问by Leslie Chong
I'm wondering what the pros and cons are of using Selenium Webdriver with the python bindings versus Java. So far, it seems like going the java route has much better documentation. Other than that, it seems down to which language you prefer, but perhaps I'm missing something.
我想知道将 Selenium Webdriver 与 Python 绑定与 Java 结合使用的优缺点是什么。到目前为止,似乎走 java 路线有更好的文档。除此之外,似乎取决于您喜欢哪种语言,但也许我遗漏了一些东西。
Thanks for any input!
感谢您提供任何意见!
采纳答案by Aurand
Generally speaking, the Java selenium web driver is better documented. When I'm searching for help with a particular issue, I'm much more likely to find a Java discussion of my problem than a Python discussion.
一般来说,Java selenium web 驱动程序的文档更好。当我针对特定问题寻求帮助时,与 Python 讨论相比,我更有可能找到有关我的问题的 Java 讨论。
Another thing to consider is, what language does the rest of your code base use? If you're running selenium tests against a Java application, then it makes sense to drive your tests with Java.
另一件要考虑的事情是,您的代码库的其余部分使用什么语言?如果您正在针对 Java 应用程序运行 selenium 测试,那么使用 Java 驱动您的测试是有意义的。
回答by user5847248
"If you're running selenium tests against a Java application, then it makes sense to drive your tests with Java." This is untrue. It makes no difference what the web application is written in.
“如果您正在针对 Java 应用程序运行 selenium 测试,那么使用 Java 驱动您的测试是有意义的。” 这是不真实的。编写 Web 应用程序的内容没有区别。
Personally I prefer python because it's equally as powerful as other languages, such as Java, and far less verbose making code maintenance less of a headache. However, if you choose a language, don't write it like you were programming in another language. For example if you're writing in Python, don't write like you were using Java.
就我个人而言,我更喜欢 python,因为它与其他语言(例如 Java)一样强大,而且不那么冗长,使代码维护不那么令人头疼。但是,如果您选择一种语言,请不要像使用另一种语言编程一样编写它。例如,如果您使用 Python 编写代码,请不要像使用 Java 那样编写代码。
回答by Amey
You've got it spot on, there are ton load of documents for Java. All the new feature implementations are mostly explained with Java. Even stackoverflow has a pretty strong community for java + selenium.
你已经明白了,Java 有大量的文档。所有新功能的实现主要是用 Java 解释的。甚至 stackoverflow 也有一个非常强大的 java + selenium 社区。
回答by Alex Okrushko
It really does not matter. Even the Documentation. Selenium lib is not big at all.
这真的没有关系。甚至是文档。Selenium lib 一点也不大。
Moreover, if you are good in development, you'll wrap selenium in your own code, and will never use driver.find(By.whatever(description))
. Also you'd use some standards and By.whatever
will become By.xpath
only.
而且,如果你擅长开发,你会把 selenium 包装在你自己的代码中,永远不会使用driver.find(By.whatever(description))
. 此外,您会使用一些标准By.whatever
并将成为By.xpath
唯一的。
Personally, I prefer python and the reason is that and my other tests for software use other python libs -> this way I can unite my tests.
就我个人而言,我更喜欢 python,原因是我的其他软件测试使用其他 python 库 -> 这样我就可以统一我的测试。
回答by munk
For me it's just a language preference. There are bindings for other languages, but I believe they communicate with Webdriver via some sort of socket interface.
对我来说,这只是一种语言偏好。有其他语言的绑定,但我相信它们通过某种套接字接口与 Webdriver 通信。