What is the difference between Selenium's Remote Control vs WebDriver?

前端 未结 2 731
予麋鹿
予麋鹿 2020-12-29 05:35

I\'m not sure I quite understand the difference. WebDriver API also directly controls the browser of choice. When should you use selenium remote control (selenium RC) instea

2条回答
  •  有刺的猬
    2020-12-29 06:41

    WebDriver is now Selenium 2. The Selenium and WebDriver code bases are being merged. WebDriver gets over a number of issues that Selenium has and Selenium gets over a number of issues that Webdriver has.

    If you have written your tests in Selenium one you don't have to rewrite them to work with Selenium 2. We, the core developers, have written it so that you create a browser instance and inject that into Selenium and your Selenium 1 tests will work in Selenium 2. I have put an example below for you.

    // You may use any WebDriver implementation. Firefox is used here as an example
    WebDriver driver = new FirefoxDriver();
    
    // A "base url", used by selenium to resolve relative URLs
    String baseUrl = "http://www.google.com";
    
    // Create the Selenium implementation
    Selenium selenium = new WebDriverBackedSelenium(driver, baseUrl);
    
    // Perform actions with selenium
    selenium.open("http://www.google.com");
    selenium.type("name=q", "cheese");
    selenium.click("name=btnG");
    

    Selenium 2 unfortunately has not been put into Selenium 2 but it shouldn't be too long until it has been added since we are hoping to reach beta in the next couple of months.

提交回复
热议问题