猿问

需要有关动态 CSS 选择器的帮助

需要有关动态 CSS 选择器的帮助。

我有我想要的 web 元素的以下 CSS 选择器:

#sub-cat-822 > div:nth-child(1) > div:nth-child(1) > form:nth-child(1) > div:nth-child(3) > div:nth-child(1) > div:nth-child(2) > input:nth-child(2)

我需要传递包含仅用于cat-822 的动态值的变量(变量名称是:Added_Main_category_id1)(在上面的 CSS 选择器中)。请有人建议如何调整上述 CSS 选择器中的变量以使其顺利运行?

所需网页元素的外部 html:

<input required="required" id="edited_name" name="sub_cate" value="" placeholder="" class="form-control" type="text">

所需网页元素的 csspath:

html body.nav-md.pace-done.modal-open div.container.body div.main_container div.right_col div.right_col_container div.right_col_wrapper div.x_panel div.x_content div.post-box ul.cat_accordion.list-group li#854.list-group-item.category-list-item-854 div.cat-name div#sub-cat-854.modal.fade.in div.modal-dialog div.modal-content form div.modal-body.clearfix div.edit-photo-poup div.col-xs-8.col-sm-6 input#edited_name.form-control

所需网页元素的 cssselector:

  #sub-cat-822 > div:nth-child(1) > div:nth-child(1) > form:nth-child(1) > div:nth-child(3) > div:nth-child(1) > div:nth-child(2) > input:nth-child(2)

所需网页元素的 xpath:

//*[@id="edited_name"]


月关宝盒
浏览 134回答 3
3回答

隔江千里

如果 id "edited_name" 在 HTML 源代码中是唯一的,则#edited_name用作 CSS 选择器
随时随地看视频慕课网APP

相关分类

Java
我要回答