0

I tried to use objectIdentifierValue

id - cntMain_chkPrimaryInvestigator_A   
name - ctl00$cntMain$chkPrimaryInvestigator_A    
xpath - //input[@id='cntMain_chkPrimaryInvestigator_A'] 
xpath - //span/div/input

but none are working,I am getting errors like "No such element found on web page".

Going through the examples given for all the other related questions I could not find a proper solution that works in a concise way that allows me to check a checkbox with a few lines of code or method.

How we can select such checkbox using a webdriver script?

Any help would be appreciated.

Here is the below html code :

<div class="input-heading nonresearchHide">
    <span id="cntMain_lbl_Primary_investigator">Primary investigator</span>
    </div>
    <div class="nonresearchHide">
    <div class="icon-info" data-content='Please add the Primary Investigator that was responsible for the research if they are not already added to this activity' data-placement="top" data-toggle="popover" data-container="body" data-trigger="hover"></div>
    <p class="defaultP">
    <div class="RadAjaxPanel" id="ctl00_ctl00_cntMain_chkPrimaryInvestigator_APanel">
    <span class="check_box">
    <input id="cntMain_chkPrimaryInvestigator_A" type="checkbox" name="ctl00$cntMain$chkPrimaryInvestigator_A" tabindex="7" />
    </span>
    </div>
    </p>
    </div>
1
  • You should be adding more details, like your code. Commented Mar 4, 2016 at 13:30

2 Answers 2

1

Use the code:

driver.findElement(By.xpath("//span[@class='check_box]")).click();

Try with clicking on span which is parent of that particular input

Sign up to request clarification or add additional context in comments.

1 Comment

I tried with above xpath but it is also not working. There has been some jquery is getting invoked in the background. Is there any way to handle jquery in selenium
0

have u tried this:

driver.findElement(By.id("cntMain_chkPrimaryInvestigator_A")).click();

if this does not help, pls show details of your code.

1 Comment

I have already tried driver.findElement(By.id("cntMain_chkPrimaryInvestigator_A")).click(); My Code is as below : element=wait.until(ExpectedConditions.visibilityOfElementLocated(By.id(objectIdentifierValue))); element.click(); element=wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(objectIdentifierValue))); element.click(); I tried with following objectIdentifierValue as ->id=cntMain_chkPrimaryInvestigator_A ->name=ctl00$cntMain$chkPrimaryInvestigator_A ->xpath=//input[@id='cntMain_chkPrimaryInvestigator_A'] ->xpath=//span/div/input

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.