简体   繁体   中英

Unexpected behavior of selenium webdriver

Meta :-

  • Firefox v51.0.1 (32-bit)
  • IE v11.576.14393.0
  • IE
  • Windows 10
  • Selenium 3.0.1
  • Geckodriver Win32 v0.13.0
  • IEDriverServer Win32 v3.0.0
  • Java v1.8.0_71

Steps to reproduce :-

  • When I use below code it launches Firefox browser :

     System.setProperty("webdriver.chrome.driver", "path/to/geckodriver.exe"); WebDriver driver = new ChromeDriver(); driver.get("https://www.google.co.in"); 
  • When I use below code it launches IE browser :

     System.setProperty("webdriver.chrome.driver", "path/to/iedriverserver.exe"); WebDriver driver = new ChromeDriver(); driver.get("https://www.google.co.in"); 

Questions :-

  • Why selenium opens browser on the basis of executable driver setting?
  • Is in both case selenium behavior is correct?
  • If correct then why we have separate driver class name like FirefoxDriver , InternetExplorerDriver , ChromeDriver etc?

The selenium project just attempts to launch the executeable and the request a new session from it. The problem here is that chromedriver readily accepts the new session request for "firefox", but it shouldn't.

It is a bug, actually, there was the thread regarding this on git hub for selenium board. If we pass chromedriver.exe for webdriver.gecko.driver , it works and opens chrome browser

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