Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html Selenium:如何定位下一个子元素_Html_Xpath_Selenium Webdriver_Css Selectors - Fatal编程技术网

Html Selenium:如何定位下一个子元素

Html Selenium:如何定位下一个子元素,html,xpath,selenium-webdriver,css-selectors,Html,Xpath,Selenium Webdriver,Css Selectors,基于第二个div.row元素前面的子元素(即页面中的第二个div.trigger元素),我无法写入该元素的确切位置 原因是,在加载页面时,最初不会出现触发器元素。但当我点击一个复选框时,会出现一个触发器,以此类推,因为页面中至少有3个复选框 很抱歉这个问题没有答案,但我还没有找到解决办法,我已经无可救药地陷入困境了。任何帮助都将不胜感激。谢谢 使用“行”类的所有div,然后使用第二个div //div[@class='row'][2] 请尝试以下类似的xpath表达式,它应该可以工作: B

基于第二个div.row元素前面的子元素(即页面中的第二个div.trigger元素),我无法写入该元素的确切位置


原因是,在加载页面时,最初不会出现触发器元素。但当我点击一个复选框时,会出现一个触发器,以此类推,因为页面中至少有3个复选框


很抱歉这个问题没有答案,但我还没有找到解决办法,我已经无可救药地陷入困境了。任何帮助都将不胜感激。谢谢

使用“行”类的所有div,然后使用第二个div

//div[@class='row'][2]

请尝试以下类似的
xpath表达式
,它应该可以工作:

By.xpath("//div[@class='settings']/child::div[position()=2][attribute::class='row']");
(或)

By.xpath("//div[@class='settings']/child::div[position()=2][attribute::class='row']");
By.xpath("//div[@class='settings']/following-sibling::chapter[position()=1]");