Toogle Button Test

Hi Team,
I am trying to automate the below toggle button
div class="toggle-slide"><div class="toggle-inner" style="width: 120px; margin-left: -50px;"><div class="toggle-on" style="height: 20px; width: 60px; text-indent: -6.66667px; line-height: 20px;">Yes</div><div class="toggle-blob" style="height: 20px; width: 20px; margin-left: -10px;"></div><div class="toggle-off active" style="height: 20px; width: 60px; margin-left: -10px; text-indent: 6.66667px; line-height: 20px;">No</div></div></div>
and i am able to run the test successfully when i am running with chrome and i am getting below error while running same via headless mode.

Unable to click on object 'Object Repository/Page_Add Address/MailOption' (Root cause: com.kms.katalon.core.exception.StepFailedException: Unable to click on object 'Object Repository/Page_Add Address/MailOption'

Caused by: org.openqa.selenium.ElementClickInterceptedException: element click intercepted: Element <div class="toggle-off active" style="height: 20px; width: 60px; margin-left: -10px; text-indent: 6.66667px; line-height: 20px;">...</div> is not clickable at point (842, 860). Other element would receive the click: <li class="select2-results__option select2-results__option--highlighted" id="select2-P37_ACCOMMODATION_STATUS-result-0og3-75" role="treeitem" aria-selected="false">...</li>
  (Session info: headless chrome=75.0.3770.90)

My code:
WebUI.click(findTestObject(‘Page_Add Address/MailOption’))
WebUI.click(findTestObject(‘Page_Add Address/Visit’))

Object property:

Hello ,

I believe, Here Headless browser is HTMLUnit browser where we are passing the different version(like Firefox Version or Chrome Version)
Whta is Headless browser?
Headless Browser uses Rhino engine so if you will test some javascript applications then chances are high you will get diff result .Generally, Headless browsers are simulation programs , they are not your real browsers.JavaScript are implemented differently by different browsers. Although JavaScript is a standard but each browser has its own little differences in the way that they have implemented JavaScript
Problem:
It is not problem with xpath, it is just you have enable the java script before proceeding your test. So, to resolve this you can configure your headless browser in project setting. below is screen shot.

Please try this and let me know if it works.

~Prabhat

1 Like

Its works fine now in headless as well.Thanks you so much. :slightly_smiling_face:

great , Happy Learning :slight_smile:
Mark it as solution, as other people will also refer this. Thanks :slight_smile:

1 Like

Yes i did.thank you

2 Likes