简体   繁体   中英

ElementNotVisibleException when running headless browser on Jenkins node. Test case runs successfully on local machine using chrome broswer

I am running Selenium headless browser on a Jenkins windows node as a part of test suite. However, it throws org.openqa.selenium.ElementNotVisibleException - element is not visible.

On my local machine, I am able to run the same test suite successfully. The only difference is that I use chrome browser instead of a headless browser.

Can someone help me with this one?

Note:

  1. I have verified that the element is visible on the page.
  2. I have tried adding wait/sleep before the page is rendered. But, it still throws exception when running on Jenkins.

I had the same problem. With me it was the headless screen size. Our Jenkins maintainer group in the company set the default screen size to 640:480 so my page didn't render the way it should. I use Xvfb for setting the screen in Jenkins, using this extra cmd/shell command:

export DISPLAY=:1 Xvfb :1 -screen 0 1920x1080x16 &

I hope this helps :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM