简体   繁体   中英

Selenium WebDriver - cssselector for locating input + onclick

I have the following checkbox:

<input id="outerLabor102" name="ctl02$chkSelectLabor" onclick="chkChildLabor(this);chkIntervallineChild(this);" type="checkbox">

I'm more of an xpath guy but since I want to come up with a selector that will find that checkbox by the input id PLUS the onclick attribute, I think a css selector should do just fine, but I can't find a way to formulate one.

I was thinking of something like:

(By.cssSelector("input[id=outerLabor102]input[onclick^=chkChildLabor(this);chkIntervallineChild(this);]")

Thanks for checking out my question.

I would not rely on the onclick attribute, but, for the sake of an example:

input#outerLabor102[onclick^=chkChildLabor]

where ^= is a starts-with notation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM