Mastodon

Protractor failed Element not interactable

While writing some Protractor tests yesterday, I came across this error:

Failed: element not interactable
  (Session info: chrome=71.0.3578.98)
  (Driver info: chromedriver=2.46.628402 (536cd7adbad73a3783fdc2cab92ab2ba7ec361e1),platform=Windows NT 10.0.16299 x86_64)
ElementNotVisibleError: element not interactable
  (Session info: chrome=71.0.3578.98)
  (Driver info: chromedriver=2.46.628402 (536cd7adbad73a3783fdc2cab92ab2ba7ec361e1),platform=Windows NT 10.0.16299 x86_64)
    at Object.checkLegacyResponse (C:\repositories\project\node_modules\selenium-webdriver\lib\error.js:546:15)
    at parseHttpResponse (C:\repositories\project\node_modules\selenium-webdriver\lib\http.js:509:13)
    at doSend.then.response (C:\repositories\project\node_modules\selenium-webdriver\lib\http.js:441:30)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:160:7)
From: Task: WebElement.click()

The reason for this error is the window size of the Chrome browser that is used by Protractor to run the tests. I don’t know why, but the windows size is only half the screen so some elements are rendered outside of the visible area. Yes I know, that’s not cross-platform, but the feature I’m developing is for desktop/laptops.

The browser window can be maximized by adding the following line to either the test setup or at the beginning of the test itself:

browser.driver.manage().window().maximize();