I'm currently facing a challenge in targeting a checkbox to agree to the terms and conditions. Unfortunately, there is no name or id that I can use for targeting. I have been attempting to use innerHTML
and innerText
in Selenium with JavaScript on Chrome, but all my efforts are leading to errors.
Here's the snippet of code I tried:
await driver.findElement(By.xpath("//*innerText[text()=’I am at least 18 years of age and agree to the Official Rules.’]")).click();
And here is the error message I encountered:
let err = new ctor(data.message)
^
InvalidSelectorError: invalid selector: Unable to locate an element with the xpath expression //innerText[text()='I am at least 18 years of age and agree to the Official
Rules.'] because of the following error:
SyntaxError: Failed to execute 'evaluate' on 'Document': The string '//innerText[text()='I am at least 18 years of age and agree to the Official Rules.']' is not a valid
XPath expression.
Could someone please help me figure out how to target this elusive checkbox?
Image of the checkbox:
Detailed properties of the checkbox: