Skip to content

webdriver.chrome.driver in headless mode can't find element #4477

Closed
@plaidshirtakos

Description

@plaidshirtakos

Meta -

OS:
Windows 10
Selenium Version:
2.53.1
Browser:
ChromeDriver 2.31.488763

Expected Behavior -

I initialized driver as shown below:

ChromeOptions chromeOptions = new ChromeOptions();
System.setProperty("webdriver.chrome.driver", "C:\\chromedriver.exe");
chromeOptions.addArguments("--headless");
driver = new ChromeDriver(chromeOptions);
driver.manage().window().maximize();

Given xpath belongs to an input field, which opens a file selector when clicked. It is working perfectly in a normal Firefox. I use WebDriverWait to wait until necessary elements appear.

wait.until(ExpectedConditions.presenceOfElementLocated(mainPage.InputFileField));

Actual Behavior -

I get following message, when I execute test:

Starting ChromeDriver 2.31.488763 (092de99f48a300323ecf8c2a4e2e7cab51de5ba8) on port 44655 Only local connections are allowed.

org.openqa.selenium.TimeoutException: Timed out after 30 seconds waiting for presence of element located by: By.xpath:

Steps to reproduce -

Please see code snippet.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions