<template>
<div id="outer">
</div>
</template>
<script>
const observer = new MutationObserver(mutations => {
// suresh's function here
});
observer.observe(document.getElementById('outer'), { childList: true });
</script>
subtag1的详细摘录
<div id="mainTag" class='mainTag'>
<div id="subMainTag1" class="subMainTag1">
<div id="subTag1" class="subTag1">
<Detail Explanation below>
<div id="subTag1" class="subTag1">
<Same as above, only difference would be some text message >
<div id="subTag1" class="subTag1">
<Same as above, only difference would be some text message>
单击subTag1时,将禁用这些禁用的行。
无法点击
<div id="mainTag" class='mainTag'> <div id="subMainTag1" class="subMainTag1"> <div id="subTag1" class="subTag1"> <div id="subTag2" class="subTag2"> <div id="subTag2A" class="subTag2A"></div> <div id="datapreview" class="dataPreview"> <!-- These below lines will not be enabled/expanded --> <div id="dataNote" class="dataNote"> <div id="titleBar" class="titleBar"> <span id="dataTime" class="datTime">9/10/2017 7:01 pm</span> <div id="deleteButton" class="deleteButton"> <img class="someimg" src="someimg"> </div> </div> <div id="contentDiv" class="contentDiv"> <div id="dataTitle" class="dataTitle">Some Data1</div> <div id="dataContent" class="dataContent">Some Data1 Body text </div> </div> </div> </div> <!-- Lines will be disabled till here--> </div> </div>
元素。
div
当我点击上述任何元素时,它会显示WebDriverException:
消息:未知错误:元素 // div [@ id =“mainTag”] / div [@ id ='subMainTag1'/ div [2]无法点击 点(433,239)。其他元素将收到点击: // div [@ id =“mainTag”] / div [@ id ='subMainTag1'/ div [2](会话信息: chrome = 60.0.3112.113)(驱动信息:chromedriver = 2.31.488774 (7e15618d1bf16df8bf0ecf2914ed1964a387ba0b),platform = Mac OS X 10.11.6 x86_64的)
答案 0 :(得分:0)
查看给定的代码结构,没有第二个或第三个兄弟,它们是孩子。您需要调整xpath以获得正确的节点。
例如,在'subMainTag1'中找到第二个'div':
ribbon.ConnectTimeout
如果您忘记了代码示例中的结束div,则添加括号应该足够了:
xpath=(//div[@id="mainTag"]/div[@id='subMainTag1']//div)[2]