Selenium Check Box Click

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Selenium Check Box Click

Renold John
I am not able to click the checkbox, I tried some XPath and CSS and id but I am not able to click on the checkbox

HTML Code:

<div class="row">
<table id="orderNoDropdown" class="table table-hover dataTable" aria-describedby="orderNoDropdown_info">
<thead>
<tr role="row">
<th class="checkBoxTh sorting_disabled" role="columnheader" rowspan="1" colspan="1">
<div class="checkbox checkbox-primary" style="float: right;">
<input id="thCheckBox" class="checkBox" type="checkbox"/>
<label for="thCheckBox" style="margin-bottom: 19px;"/>
</div>
</th>

I Try this Xpath and css 


XPath:

.//*[@id='orderNoDropdown']/thead/tr/th[1]/div/label

//th/div/label

CSS:

 div.checkbox.checkbox-primary > label

This is My Error

Is Terms and condition checkbox displayed: false
Is Terms and condition checkbox enabled: true
Default Terms and Condition checkbox status: false
log4j:WARN No appenders could be found for logger (freemarker.cache).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
[Utils] Attempting to create C:\Users\Tabbie\tekafforde1\Tekafforde.com\test-output\Default suite\Default test.xml
[Utils]   Directory C:\Users\Tabbie\tekafforde1\Tekafforde.com\test-output\Default suite exists: true
FAILED: Purchase_multi
org.openqa.selenium.ElementNotVisibleException: element not visible


This is my Java Code
WebElement tcCheckbox = driver.findElement(By.cssSelector("input#thCheckBox")); //tcCheckbox.click(); //System.out.println("is clickkkkkkkkkkkkkkkkkkkkkkkkkkkkk"); //Thread.sleep(8000); boolean tcCheckIsDisplayed = tcCheckbox.isDisplayed(); System.out.println("Is Terms and condition checkbox displayed: "+tcCheckIsDisplayed); boolean tcCheckboxIsEnabled = tcCheckbox.isEnabled(); System.out.println("Is Terms and condition checkbox enabled: "+tcCheckboxIsEnabled); boolean tcCheckboxIsSelected = tcCheckbox.isSelected(); System.out.println("Default Terms and Condition checkbox status: "+tcCheckboxIsSelected); tcCheckbox.click(); Thread.sleep(2000); boolean tcCheckboxNewStatus = tcCheckbox.isSelected(); System.out.println("Terms and Condition checkbox status after perform click() event: "+tcCheckboxNewStatus); // tcCheckbox.click(); Thread.sleep(5000);


--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/b1bf0a8d-5ee9-4f21-a5e4-aac8dd9b9cbe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Selenium Check Box Click

Ankit Gupta-2
Use Move over, moveByElement, sometimes checkbox won't be clickable then moveByElement would work.

On Thu, May 3, 2018 at 11:39 AM, Renold John <[hidden email]> wrote:
I am not able to click the checkbox, I tried some XPath and CSS and id but I am not able to click on the checkbox

HTML Code:

<div class="row">
<table id="orderNoDropdown" class="table table-hover dataTable" aria-describedby="orderNoDropdown_info">
<thead>
<tr role="row">
<th class="checkBoxTh sorting_disabled" role="columnheader" rowspan="1" colspan="1">
<div class="checkbox checkbox-primary" style="float: right;">
<input id="thCheckBox" class="checkBox" type="checkbox"/>
<label for="thCheckBox" style="margin-bottom: 19px;"/>
</div>
</th>

I Try this Xpath and css 


XPath:

.//*[@id='orderNoDropdown']/thead/tr/th[1]/div/label

//th/div/label

CSS:

 div.checkbox.checkbox-primary > label

This is My Error

Is Terms and condition checkbox displayed: false
Is Terms and condition checkbox enabled: true
Default Terms and Condition checkbox status: false
log4j:WARN No appenders could be found for logger (freemarker.cache).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
[Utils] Attempting to create C:\Users\Tabbie\tekafforde1\Tekafforde.com\test-output\Default suite\Default test.xml
[Utils]   Directory C:\Users\Tabbie\tekafforde1\Tekafforde.com\test-output\Default suite exists: true
FAILED: Purchase_multi
org.openqa.selenium.ElementNotVisibleException: element not visible


This is my Java Code
WebElement tcCheckbox = driver.findElement(By.cssSelector("input#thCheckBox")); //tcCheckbox.click(); //System.out.println("is clickkkkkkkkkkkkkkkkkkkkkkkkkkkkk"); //Thread.sleep(8000); boolean tcCheckIsDisplayed = tcCheckbox.isDisplayed(); System.out.println("Is Terms and condition checkbox displayed: "+tcCheckIsDisplayed); boolean tcCheckboxIsEnabled = tcCheckbox.isEnabled(); System.out.println("Is Terms and condition checkbox enabled: "+tcCheckboxIsEnabled); boolean tcCheckboxIsSelected = tcCheckbox.isSelected(); System.out.println("Default Terms and Condition checkbox status: "+tcCheckboxIsSelected); tcCheckbox.click(); Thread.sleep(2000); boolean tcCheckboxNewStatus = tcCheckbox.isSelected(); System.out.println("Terms and Condition checkbox status after perform click() event: "+tcCheckboxNewStatus); // tcCheckbox.click(); Thread.sleep(5000);


--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/b1bf0a8d-5ee9-4f21-a5e4-aac8dd9b9cbe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CAKrer0DwTwkP4r%3Dd6N4WnkepdoYU0VgRgDsGaZmfW-GzGQRoqg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.