[英]First steps with Selenium RC
I am trying to move the first steps in web scraping.我正在尝试移动 web 抓取的第一步。 I read about selenium and seems to me that it fit for what i am looking for.
我阅读了有关 selenium 的信息,在我看来它适合我正在寻找的东西。 But i have some problems to start.
但我有一些问题要开始。 I am following this tutorial selenium getting started and i am trying to compile the first example with my linux ubuntu. I have compiled in this way
我正在按照本教程selenium 入门,我正在尝试用我的 linux ubuntu 编译第一个示例。我以这种方式编译
javac -classpath selenium-server-standalone-2.20.0.jar Example.java
javac -classpath selenium-server-standalone-2.20.0.jar 示例.java
i have started selenium server with我已经启动了 selenium 服务器
java -jar selenium-server-standalone-2.20.0.jar
java-jar selenium-server-standalone-2.20.0.jar
but i can't run Example.但我无法运行示例。 This way doesn't works
这种方式行不通
java Example
java 示例
and this way too也是这样
java -classpath selenium-server-standalone-2.20.0.jar Example
java -classpath selenium-server-standalone-2.20.0.jar 示例
I guess that the grammar is wrong, but where?我猜语法是错误的,但是在哪里?
You need to include the current directory in the classpath like so:您需要像这样在类路径中包含当前目录:
java -cp .:selenium-server-standalone-2.20.0.jar Example
Also since you did not actually put the Example.java
in org.openqa.selenium.example
, you probably want to delete the package org.openqa.selenium.example
in the first line of the source.此外,由于您实际上并未将
Example.java
放入org.openqa.selenium.example
中,因此您可能想要删除源代码第一行中的package org.openqa.selenium.example
。
While writing code in Java a better approach would be using an IDE like Eclipse. Once you link the JARs and import them in your Java classes you can write your code quickly and efficiently.在 Java 中编写代码时,更好的方法是使用 IDE,例如 Eclipse。一旦链接 JARs 并将它们导入 Java 类,您就可以快速高效地编写代码。
On top of that, Eclipse has lot of plugins for testing software like Junit, TestNG's to help you create better test suites.最重要的是,Eclipse 有很多用于测试软件的插件,例如 Junit,TestNG 可以帮助您创建更好的测试套件。
Not to mention a Java IDE is always helpful in debugging test code.更不用说一个 Java IDE 总是有助于调试测试代码。 Here is a tutorial on how to setup Eclipse with Selenium: link
这是有关如何使用 Selenium 设置 Eclipse 的教程: 链接
Hope it helps.希望能帮助到你。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.