How to debug Webdriver's source code in eclipse

Source: Internet
Author: User
Tags testng

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.