0

I have been question about selenium test with chrome headless variant. Sometimes test is waiting anything, why is it has long time 10 minutes? I added into tests timeout 40 sec.

15:41:54 INFO: Selenium WebDriver v. 3.14.0 build time: 2018-08-02T20:19:58.91Z
15:41:54 Oct 12, 2018 12:41:55 PM com.codeborne.selenide.impl.WebDriverThreadLocalContainer createDriver
15:41:54 INFO: Create webdriver in current thread 1: ChromeDriver -> ChromeDriver: chrome on LINUX (6332d1a2dee8e95f05da4130b99237f9)
15:51:54 [34mEmbed Failed timeout
15:51:54   (Session info: chrome=69.0.3497.100)
15:51:54   (Driver info: chromedriver=2.41.578700 (2f1ed5f9343c13f73144538f15c00b370eda6706),platform=Linux 3.10.0-862.14.4.el7.x86_64 x86_64) (WARNING: The server did not provide any stacktrace information)
15:51:54 Command duration or timeout: 0 milliseconds

Selenium settings:

    case "chrome":
        testBrowserName = "CH";
        WebDriverManager.chromedriver().setup();
        ChromeOptions chromeOptions = new ChromeOptions();
        chromeOptions.addArguments("--disable-dev-shm-usage");
        chromeOptions.addArguments("--no-sandbox");
        chromeOptions.addArguments("--headless");
        chromeOptions.addArguments("--window-size=1920,1080");
        ChromeDriver driver = new ChromeDriver(chromeOptions);
        WebDriverRunner.setWebDriver(driver);
        break;
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
Zak Shirak
  • 89
  • 4
  • 12

1 Answers1

0

You havn't mentioned about your usecase in details and it is not clear why you would use restrict your tests to ChromeDriver implementation only.

If you use ChromeDriver driver = new ChromeDriver(); the ChromeDriver instance which will get created will be only able to invoke and act on the methods implemented by ChromeDriver and supported by Chrome Browser only. To act with other browsers you have to specifically create individual objects as below :

  • FirefoxDriver driver = new FirefoxDriver();
  • InternetExplorerDriver driver = new InternetExplorerDriver();

WebDriver Interface

From Selenium perspective, the WebDriver Interface is similar like a agreement which the 3rd party Browser Vendors like Mozilla, Chrome, Internet Explorer, Safari, etc have to adhere and implement the same. This would in-turn help the end-users to use the exposed APIs to write a common code and implement the functionalities across all the available Browsers without any change.

You will find a detailed discussion in what is the difference between ChromeDriver and WebDriver in selenium?

Solution

Instead of using the ChromeDriver implementation switch to the WebDriver Interface. As per current scenario, we have to instantiate the implementations of WebDriver Interface directly. The current practice is, we need to write our Automated Test Script against this interface so that in future we may swap in a more fully featured Browser when there is a requirement for one.

Example:

case "chrome":
    testBrowserName = "CH";
    WebDriverManager.chromedriver().setup();
    ChromeOptions chromeOptions = new ChromeOptions();
    chromeOptions.addArguments("--disable-dev-shm-usage");
    chromeOptions.addArguments("--no-sandbox");
    chromeOptions.addArguments("--headless");
    chromeOptions.addArguments("--window-size=1920,1080");
    WebDriver driver = new ChromeDriver(chromeOptions);
    WebDriverRunner.setWebDriver(driver);
    break;
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352