3

I have my front end automation suite running in Selenium Cucumber and unfortunately the chrome driver is unable to locate the element. The server has network connections and I am able to ping the url from the CI server.

            [14:35:40][Step 1/1]       org.openqa.selenium.TimeoutException: Expected condition failed: waiting for visibility of Proxy element for: DefaultElementLocator 'By.id: login_email' (tried for 60 second(s) with 500 milliseconds interval)
            [14:35:40][Step 1/1]        at org.openqa.selenium.support.ui.WebDriverWait.timeoutException(WebDriverWait.java:81)
            [14:35:40][Step 1/1]        at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:271)
            [14:35:40][Step 1/1]        at stepdefs.LoginSteps.iFillEmailWithValidEmailAddress(LoginSteps.java:115)
            [14:35:40][Step 1/1]        at ?.When I fill email with valid OTA email address(login.feature:6)
            [14:35:40][Step 1/1]       Caused by: org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"id","selector":"login_email"}
            [14:35:40][Step 1/1]         (Session info: headless chrome=69.0.3497.100)
            [14:35:40][Step 1/1]         (Driver info: chromedriver=2.42.591071 (0b695ff80972cc1a65a5cd643186d2ae582cd4ac),platform=Linux 4.9.0-6-amd64 x86_64) (WARNING: The server did not provide any stacktrace information)
            [14:35:40][Step 1/1]       Command duration or timeout: 0 milliseconds
            [14:35:40][Step 1/1]       For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
            [14:35:40][Step 1/1]       Build info: version: '3.13.0', revision: '2f0d292', time: '2018-06-25T15:24:21.231Z'
            [14:35:40][Step 1/1]       System info: host: 'intelligence-teamcity', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.9.0-6-amd64', java.version: '1.8.0_181'
            [14:35:40][Step 1/1]       Driver info: org.openqa.selenium.chrome.ChromeDriver
            [14:35:40][Step 1/1]       Capabilities {acceptInsecureCerts: false, acceptSslCerts: false, applicationCacheEnabled: false, browserConnectionEnabled: false, browserName: chrome, chrome: {chromedriverVersion: 2.42.591071 (0b695ff80972cc..., userDataDir: /appdata/TeamCity/buildAgen...}, cssSelectorsEnabled: true, databaseEnabled: false, goog:chromeOptions: {debuggerAddress: localhost:20897}, handlesAlerts: true, hasTouchScreen: false, javascriptEnabled: true, locationContextEnabled: true, mobileEmulationEnabled: false, nativeEvents: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: LINUX, platformName: LINUX, rotatable: false, setWindowRect: true, takesHeapSnapshot: true, takesScreenshot: true, unexpectedAlertBehaviour: , unhandledPromptBehavior: , version: 69.0.3497.100, webStorageEnabled: true}
            [14:35:40][Step 1/1]       Session ID: d4f4672a9d49645e1bc8af8b54627aae

Here is how I am creating my Chrome driver instance though.

System.setProperty("webdriver.chrome.driver",
            "browser-drivers/chromedriver");
final ChromeOptions chromeOptions = new ChromeOptions();
    chromeOptions.addArguments("--no-sandbox");
    chromeOptions.addArguments("--allow-running-insecure-content");
    chromeOptions.addArguments("window-size=1920x1080");
    chromeOptions.addArguments("--disable-gpu");
    chromeOptions.addArguments("--disable-extensions");
    chromeOptions.setExperimentalOption("useAutomationExtension", false);
    chromeOptions.addArguments("--proxy-server='direct://'");
    chromeOptions.addArguments("--proxy-bypass-list=*");
    DesiredCapabilities capabilities = DesiredCapabilities.chrome();
    capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);

    chromeDriver = new ChromeDriver(capabilities);

What am I doing wrong here? why does it work on mine and not in the server (It has Chrome installed as well)? Any help would be much appreciated.

UPDATE: It works fine when its run with the UI. Just headless is not working

AnOldSoul
  • 4,017
  • 12
  • 57
  • 118
  • Update the question with the relevant HTML – undetected Selenium Sep 21 '18 at 08:32
  • I am not allowed to upload the HTML. But using the ID that I've used I am able to access the element and it runs perfectly in my machine as well. That's what I don't understand – AnOldSoul Sep 21 '18 at 08:35
  • Factually the error stack trace of `org.openqa.selenium.TimeoutException` have no relation with your question heading **`times out trying to load the page`** – undetected Selenium Sep 21 '18 at 08:54
  • I have edited the question. Thanks for pointing it out. But its pretty straight forward as its a login page which just has an email id element and a pwd element. So I made the assumption that page is not loading at all – AnOldSoul Sep 21 '18 at 09:00
  • you are getting an execption that the element can't be found, yet you don't post the code where you try to find the element? – Corey Goldberg Sep 21 '18 at 19:37

2 Answers2

1

Looks like the headless mode doesn't support insecure certificates, and then the page just won't open, opening just a blank page and not finding anything in it.

Just add these two capabilities, apart from the chromeOptions one, to the DesiredCapabilities object:

capabilities.setCapability("acceptSslCerts", true);
capabilities.setCapability("acceptInsecureCerts", true);
0

I've had similar issues back in my frontend testing days. Try downgrading to stable Chrome / Chrome driver versions and see if this fixes anything. Most of the times irrational issues like these were solved just by downgrading to certain versions.