Check box is not checked using xpath, it opens link


Check box is not checked using xpath, it opens link



Please see attached screen shots Agree Term Check box



using xpath "//div[@id='divTermsNdConditions']/div/div/div/label" it clicks on the label and open term and condition link


xpath "//div[@id='divTermsNdConditions']/div/div/div/label"



If use input id 'IsAgreeToNorms' then element is not visible/reachable.


'IsAgreeToNorms'



What will be the solution to click on check box and checked?





What is the HTML when the checkbox is checked?
– demouser123
Jun 28 at 9:38





on click on it. it checked. That i want to do with selenium automation
– Samir 007
Jun 28 at 9:53




2 Answers
2



Xpath should be


"//div[@id='divTermsNdConditions']/div/div/div/input"



but why not use the ID of checkbox like this:


//input[@id='IsAgreeToNorms']



And if you use webdriver in a Java/python context, you do not even have to use XPath but locate the element straight by id.



If the element is not "visible/reachable", then it is not a problem related to location but may be due to page logic or a timing issue. From the information given, it is impossible to say.



You can try to click it with Explicit Wait,


WebDriverWait wait = new WebDriverWait(driver, 20);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//input[@data-val-required="Your String Value"]")));



You can use any attribute value if its unique,


//input[@data-val-required="Your attribute Value"]
//input[@name="Your attribute Value"]



You can also use, ExpectedConditions.elementToBeClickable


ExpectedConditions.elementToBeClickable





Visibility condition was failed as you see <input id='IsAgreeToNorms'> show disable. So it won't work
– Samir 007
Jun 30 at 9:37





@Samir007 Please refer my updated answer
– Ishita Shah
Jun 30 at 9:42






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Render GeoTiff to on browser with leaflet

How to get chrome logged in user's email id through website

using states in a react-navigation without redux