org.openqa.selenium.WebDriverException: Error forwarding the new session cannot find : Capabilities

前端 未结 1 1302
误落风尘
误落风尘 2020-12-19 18:56

Hub starting command :

java -jar selenium-server-standalone-3.11.0.jar -role hub

Node starting command :

java -Dwebdriver.c         


        
相关标签:
1条回答
  • 2020-12-19 19:38

    This error message...

    Exception in thread "main" org.openqa.selenium.WebDriverException: Error forwarding the new session cannot find : Capabilities {browserName: chrome, platform: macOS 10.12, version: }
    

    ...implies that the ChromeDriver wasn't able to initiate an active connection with the WebClient i.e Chrome browser.

    Your main issue is the version compatibility between the binaries you are using as follows :

    • You are using chromedriver=2.36
    • Release Notes of chromedriver=2.36 clearly mentions the following :

    Supports Chrome v63-65

    • You are using chrome=66.0
    • Release Notes of ChromeDriver v2.38 clearly mentions the following :

    Supports Chrome v65-67

    So there is a clear mismatch between the ChromeDriver version (v2.36) and the Chrome Browser version (v66.0)

    Solution

    • Upgrade ChromeDriver to current ChromeDriver v2.38 level.
    • Keep Chrome version at Chrome v66.x levels. (as per ChromeDriver v2.38 release notes)
    • Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
    • Use CCleaner tool to wipe off all the OS chores before and after the execution of your test Suite.
    • If your base Web Client version is too old, then uninstall it through Revo Uninstaller and install a recent GA and released version of Web Client.
    • Take a System Reboot.
    • Execute your @Test.

    Update A

    As per your question update while working with Selenium 3.x you need to replace the keyword webdriver with node and remove the extension (.exe) of the WebDriver variant as follows :

    • Mac OS X :

      java -Dwebdriver.chrome.driver=/Users/alina/Selenium/chromedriver -jar selenium-server-standalone-3.11.0.jar -role node -hub http://192.168.100.4:4444/grid/register/
      

    Update B

    As you are still facing the same error let us address the error :

    Using `new ChromeOptions()` is preferred to    `DesiredCapabilities.chrome()`
    

    As per the error message you need to use the merge() method from MutableCapabilities Class to merge the DesiredCapabilities type of object into ChromeOptions type object and initiate the RemoteWebDriver and WebClient instance by passing the ChromeOptions object as follows :

    System.setProperty("webdriver.chrome.driver", "/Users/username/chromedriver");
    nodeUrl = "http://192.168.100.4:4444/wd/hub";
    DesiredCapabilities capabilities = DesiredCapabilities.chrome();
    capabilities.setPlatform(Platform.SIERRA);
    ChromeOptions options = new ChromeOptions();
    options.merge(capabilities);
    driver = new RemoteWebDriver(new URL(nodeUrl), options);
    driver.get("http://www.amazon.com");
    

    PS : As a reference you can have a look at the discussions in mutablecapabilities tag

    0 讨论(0)
提交回复
热议问题