4

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.
TT_
  • 385
  • 1
  • 2
  • 14
  • May I suggest that instead of using wait and sleep..check simply for presence of element in an infinite loop which will keep on checking for presence of element if it never comes out of the loop then for sure its not able to load that element and you would know where things are wrong – Mrunal Gosar Jul 14 '16 at 08:18
  • Thanks for your reply. However, it was due to some other reason. We found out that in some cases the background page had a similar xpath and hence the element was not visible as the wrong element was being identified. – TT_ Jul 18 '16 at 12:25

1 Answers1

1

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 :)