Hi,
For a certain TC I need to click in a switch button. In one part of the switch it says yes and in the other one it says no.
Whenever I try to click it, nothing happens. This is how I do it:
CustomKeywords.'keywordPrueba.CustomFunction.clickUsingJS'(findTestObject('Localhost Repository/Page_Emisin de Informe de Resultados/div_SINO_reimprimir'), 5)
This is the html of the switch button when it says yes:
This is the html of the switch button when it says no
:
Xpath:
As you may notice the class of the div changes.
Any suggestions on how to resolve this?
You either want to target the input type="checkbox"
or the third <span>
- I’d favor the checkbox.
1 Like
You need to target the <input>
element, as this likely has the relevant event listener for your JS click.
Thanks both for the reply. I do not really get what do you mean by that. Its something like this?
WebDriver driver = DriverFactory.getWebDriver()
WebElement buttonCheck = driver.findElement(By.id("REIMPRIMIRContainer_check"))
buttonCheck.click()
because this does not work.
Basically, your XPath is targeting the wrong element (a <div>
). You need to make it target the checkbox instead. @Brandon_Hein can help you fix that (me no do no xpath 
Just change your locator in your test object to target the <input>
element. Right now, it’s targeting some ancestor <div>
. Try this xpath:
//div[@id='REIMPRIMIRContainer']//input
Thanks a lot. I will try and do that.
Hi @guillenoble59 so it seems that you are trying to click either on the SI option or the NO option depending of each test cases. Why dont you try defining this 2 objects with the following xpaths:
//span[text()=‘SI’]
//span[text()=‘NO’]
then you can try clicking on one of them or both and let see what happens
Thanks everyone for your replies. This worked for me !