When you read the work of Webdriver this blog post, is not also eager to confirm the article in the theory is not correct, I would like to see the source code Webdriver, and debugging, through the code to more in-depth understanding of webdriver working principle. OK, no problem, we'll tell you next how to load the source code into eclipse. The specific contents are as follows:
Pre-conditions
You need to create a Java project in eclipse first, the specific steps are not detailed, I believe that a bit of basic should be able to create a successful. Then go to selenium website to download selenium client. Please see the specific download location:
The content of the general download is a ZIP package, the content after decompression is as follows:
Add all the jar packages and Selenium-java-2.39.0.jar in the Libs directory, Selenium-java-2.39.0-srcs.jar to the Java Project build path, and create a class yourself, It contains a simple code of Webdriver, which reads as follows:
1 package testcases; 2 3 import org.openqa.selenium.By; 4 import org.openqa.selenium.WebDriver; 5 import org.openqa.selenium.WebElement ; 6 Import Org.openqa.selenium.firefox.FirefoxDriver; 7 Import Org.testng.annotations.Test; 8 9 public class testcase02{10 one @Test12 public void Open_baidu () { Webdriver driver = new Firefoxdriver (); driver.get ("http://www.baidu.com"); webelement element1 = driver.findelement ( By.id ("kw")), Element1.sendkeys ("Selenium"), webelement btn = driver.findelement (by.id ("su")); 19 Btn.click (); }22 23 24}
To load the source code, proceed as follows:
1. Open the Declaration of the interface Webdriver and you will see "Source not Found" as shown
2. Then click Attach Source ..., pop-up window, put the path of the Selenium-java-xxx-srcs.jar package contained in the cliet you just downloaded, and click the OK button
3. You'll be able to see the source code of Webdriver.
4. In this way, add a breakpoint in the test program and select Debug as TestNG test to debug the Webdriver source code.
Transferred from: http://www.cnblogs.com/testermark/p/3551663.html
How to debug Webdriver source code in Eclipse (GO)