Chrome Headless element not visible

element not interactable headless chrome
headless chrome unable to locate element:
selenium headless chrome no such element
chromedriver headless not working in headless mode can't find element
chrome options headless
debugging headless chrome
headless chrome tutorial

I am facing following error while trying to interact one editbox inside an iframe.

Please note code is working fine, if I don't run that it in headless mode. Issue only occurs when I run in headless mode.


org.openqa.selenium.ElementNotVisibleException: element not visible


org.openqa.selenium.ElementNotVisibleException: element not visible
  (Session info: headless chrome=60.0.3112.113)
  (Driver info: chromedriver=2.33.506092 (733a02544d189eeb751fe0d7ddca79a0ee28cce4),platform=Linux 4.9.51-10.52.amzn1.x86_64 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 21 milliseconds
Build info: version: '2.53.0', revision: '35ae25b1534ae328c771e0856c93e187490ca824', time: '2016-03-15 10:43:46'
System info: host: 'ip-172-31-41-152', ip: '', 'Linux', os.arch: 'amd64', os.version: '4.9.51-10.52.amzn1.x86_64', java.version: '1.8.0_45'
Driver info:
Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, networkConnectionEnabled=false, chrome={chromedriverVersion=2.33.506092 (733a02544d189eeb751fe0d7ddca79a0ee28cce4), userDataDir=/tmp/.org.chromium.Chromium.aRCh3q}, takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=60.0.3112.113, platform=LINUX, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true, setWindowRect=true, unexpectedAlertBehaviour=}]
Session ID: ebc4a4ce4a038d2440aedb1f4d952a64
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(
    at java.lang.reflect.Constructor.newInstance(
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(
    at org.openqa.selenium.remote.RemoteWebDriver.execute(
    at org.openqa.selenium.remote.RemoteWebElement.execute(
    at com.medexpress.pages.Buyer.CheckoutPage.submitPage(
    at com.medexpress.steps.Order.Submits_the_order(
    at ✽.And Submits the order(com/medexpress/steps/2oder_checkout.feature:44)

To solve this issue, I am trying to scroll to that Iframe or the element which will bring this iframe in focus. I have tried following things. However nothing is working. it's not scrolling to given element.

Scroll Using Native Events


Scroll using JavaScript

Actions actions = new Actions(driver);
JavascriptExecutor js = (JavascriptExecutor)driver;
js.executeScript("arguments[0].scrollIntoView()", element);

Scroll to end of page using javascript


above code is not working and gives following error.

org.openqa.selenium.WebDriverException: unknown error: Runtime.evaluate threw exception: SyntaxError: Invalid or unexpected token

Please note that all the above code is working on chrome, only issue with headless.

Drive Code

ChromeOptions chromeOptions = new ChromeOptions();
driver = new ChromeDriver(chromeOptions);

If an element is visible (it has height and width greater than 0), it clicks that element without the need to scroll.

I had the same issue, and fixed it by making the window as FullHD, so just change this line:




Don't know the syntax of Java since I fixed it in C#, but it's worth the try.

Headless Element not visible - Web Testing, Click only works in Chrome but not in Chrome headless. Unable to click on object '' (Root cause: org.openqa.selenium. When I run test script in headless mode chrome browser, element link is not visible, is not able to do in head mode is everything OK. All other info are in stacktrace. All other info are in stacktrace.

Faced similar issue. The following lines of code worked for me -


Source -

Element is not clickable in Chrome Headless · Issue #4685 , I have a problem with clicking on the element from headless Chrome this visible of browser having Chrome 61 Webdriver 3.5.3 and chrome  I have a problem with clicking on the element from headless Chrome this call worked some time Without Headless Chrome and does not work at all with Headless Call driver.FindElement(By.Id("createBtn")) Element {Element (id = 0.18579689918

Increasing the "window-size" fixed the error in the Gulp-Protractor

browserName: 'chrome',
chromeOptions: {
args: [ "--headless", "--disable-gpu", "--window-size=1200,900" ]

Failed: element not interactable in headless chrome · Issue #5273 , Failed: element not interactable in headless chrome #5273 Jasmine Spec Runner output visible in browser }, coverageIstanbulReporter: { dir:  With headless I get this problem. What I have seen is that the field at first is not visible. only when you update some other fields a jquery is set to make the css locator visible. I checked in google inspect and the field is unique. I use the actions object to select the click button. When I do the same test (not headless) then it passes.

chromedriver in headless mode doesn't work correctly because of , setExpirementalOption("useAutomationExtension",false) because without it, (​even in non-headless mode) I get a warning box "Can't load  Headless chrome is not correctly picking up have_selector or has_selector or any other approach through Selenium to verify an element exists. I found a workaround though. Not sure why, because it works on some elements and on some not. Anyway, I ended up doing something like this (Note I am doing it in ruby)

1965 - Headless Chromedriver fails to locate components , Selenium reports element is NOT found:=> NoSuchElementError: No I tested it with phantomjs, with firefox, with regular visible chrome and  If an element is not visible on screen but is visible on the page i would expect the driver to click it anyway. This behavior is present in 3.5.2 Actual Behavior -

Getting Started with Headless Chrome | Web, Getting started with Headless Chrome. DevTools Digest: Efficient Element Edits, Service Worker Debugging, and Material Design Shades · Web Essentially, running Chrome without chrome! A headless browser is a great tool for automated testing and server environments where you don't need a visible UI shell. The Chrome Headless browser was unable to identify the element even it is mentioned with id in the test case. While running the same test case in chrome browser it was working perfectly fine and was failing whe…

  • so did you solve it?