How to address the log INFO Using `new FirefoxOptions()` is preferred to `DesiredCapabilities.firefox()` in selenium project

后端 未结 1 2040
时光取名叫无心
时光取名叫无心 2021-01-19 01:50

I just started a selenium project, but things didn\'t got right, so after searching a bit I found this solution. It works but i can\'t understand what these red statements w

相关标签:
1条回答
  • This INFO log message:

    INFO: Using `new FirefoxOptions()` is preferred to `DesiredCapabilities.firefox()`
    

    is the result of the changes incorporated in:

    • Selenium v3.0.0-beta4

      Added ability to use FirefoxOptions when starting firefox.
      
    • Selenium v3.5.0

      * Start making *Option classes instances of Capabilities. This allows
        the user to do:
      
        `WebDriver driver = new RemoteWebDriver(new InternetExplorerOptions());`
      

    If your usecase is to explicitly mention the absolute location of the FirefoxBinary you can use the following solution:

    • Using FirefoxOptions:

      import org.openqa.selenium.WebDriver;
      import org.openqa.selenium.firefox.FirefoxDriver;
      import org.openqa.selenium.firefox.FirefoxOptions;
      
      public class A_Firefox_binary 
      {
          public static void main(String[] args) 
          {
              System.setProperty("webdriver.gecko.driver", "C:/Utility/BrowserDrivers/geckodriver.exe");
              FirefoxOptions options = new FirefoxOptions();
              options.setBinary("C:\\Program Files\\Mozilla Firefox\\firefox.exe");
              WebDriver driver =  new FirefoxDriver(options);
              driver.get("https://stackoverflow.com");
              System.out.println("Page Title is : "+driver.getTitle());
              driver.quit();
          }
      }
      
    • Console Output:

      Page Title is : Stack Overflow - Where Developers Learn, Share, & Build Careers
      
    0 讨论(0)
提交回复
热议问题