1

I have following html:

<input id="!T1319457706_SPY" type="checkbox" name="!T1319457706_SPY" class="checkbox" onclick="toggleTextField(['1319457706'],this.checked,'','');" style="">

This is checkbox that I want to click,I have tried all the selector to locate it,but all failed and system have no error message,in this page I have tried to click other element,it works,expect this checkbox.

I have tried follow ways:

driver.find_element_by_id('!T1319457706_SPY').click()
driver.find_element_by_css_selector("input[name='!T1319457706_SPY']").click()
driver.find_element_by_xpath("//body[@class='grdtradeOrder']//form[@name='displayopenorders']//table[@class='t0']//tr[@name='orderid1319457706']//input[@name='!T1319457706_SPY']").click()

I also tried use:

 click_check=driver.find_element_by_id('!T1319457706_SPY')

 driver.execute_script("arguments[0].click();", click_check)

All above tries have failed.Any friend can help?

2 Answers 2

1

I guess that clicking the checkbox calls a javascript code as seen from the onClick expression in the HTML code.

You could directly execute that javascript code using the execute_script function

driver.execute_script(""toggleTextField(['1319457706'],this.checked,'','');")

Or maybe this answer could help you. This clicks on the checkbox using Javascript.

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

Comments

0
click_check = driver.find_element_by_css_selector("input[onclick*='toggleTextField']")
driver.execute_script("arguments[0].click();", click_check)

Comments

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.