简体   繁体   中英

First steps with Selenium RC

I am trying to move the first steps in web scraping. I read about selenium and seems to me that it fit for what i am looking for. 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

javac -classpath selenium-server-standalone-2.20.0.jar Example.java

i have started selenium server with

java -jar selenium-server-standalone-2.20.0.jar

but i can't run Example. This way doesn't works

java Example

and this way too

java -classpath selenium-server-standalone-2.20.0.jar Example

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.

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.

On top of that, Eclipse has lot of plugins for testing software like Junit, TestNG's to help you create better test suites.

Not to mention a Java IDE is always helpful in debugging test code. Here is a tutorial on how to setup Eclipse with Selenium: link

Hope it helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM