1

I'm running some UI tests with selenium and TestNG. All test cases are passed when executed with Firefox driver. But when I use HtmlUnitDriver, one test case fails where it requires accepting a confirmation pop up message by clicking on the button. Is there a workaround for this?

Krishnan Mahadevan
  • 14,121
  • 6
  • 34
  • 66
Pubudu
  • 478
  • 1
  • 6
  • 22
  • Your code trials and `HTML` please. – undetected Selenium Dec 14 '17 at 09:15
  • _Unable to detect_ Are you getting any error ? – NarendraR Dec 14 '17 at 11:09
  • @NarendraR : I am seeing the following error in headless mode with HtmlUnitDriver. But with FirefoxDriver it's working fine. – Pubudu Dec 15 '17 at 05:18
  • org.openqa.selenium.NoSuchElementException: Unable to locate a node using //button[@type='button'] – Pubudu Dec 15 '17 at 05:19
  • There might be some resolution issue. headless mode open in default screen resolution so may be you web responsiveness get changes so it wont find that element. take the screenshot and compare. better to use PhantomJS driver for that as there is issue in taking screenshot using HTMLUnit – NarendraR Dec 15 '17 at 06:02

1 Answers1

0

It might be possible that the button you are trying to click is not visible to the driver in headless mode. Try taking a screenshot to make sure it appears on the screen. You can have a condition which checks if the button is visible before clicking it.

Subham Pasari
  • 339
  • 2
  • 5