简体   繁体   English

Selenium WebDriver-用于选择输入和onclick的cssselector

[英]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. 我更是一个xpath家伙,但是由于我想提供一个选择器,该选择器将通过输入ID加上onclick属性来找到该复选框,因此我认为css选择器应该可以,但是我找不到方法制定一个。

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: 我不会依赖onclick属性,但是,为了举例说明:

input#outerLabor102[onclick^=chkChildLabor]

where ^= is a starts-with notation. 其中^=起始符号。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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