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
xpath来定位Robot框架中id为动态的按钮_Xpath_Robotframework - Fatal编程技术网

xpath来定位Robot框架中id为动态的按钮

xpath来定位Robot框架中id为动态的按钮,xpath,robotframework,Xpath,Robotframework,我正在使用RobotFramework进行自动化测试,我在点击一个id本质上是动态的按钮时遇到了一个问题,点击它会得到一个弹出窗口 我只能测试XPath,但是使用 //div[@id='button-1571']/descendant::button[contains(@class, 'x-btn-center')]/ span[contains(@class,'x-btn-icon icon-plus')] 选择的不是按钮,而是跨度:

我正在使用RobotFramework进行自动化测试,我在点击一个id本质上是动态的按钮时遇到了一个问题,点击它会得到一个弹出窗口


我只能测试XPath,但是使用

//div[@id='button-1571']/descendant::button[contains(@class, 'x-btn-center')]/  
                         span[contains(@class,'x-btn-icon icon-plus')]
选择的不是按钮,而是跨度:

或者,就像第二个符号一样

//div[@id='button-1571']/descendant::button[contains(@class, 'x-btn-center')]/
                     span[contains(@class,'x-btn-icon icon-plus')]/parent::button
它是这个范围的父按钮,是上面XPath的结果:

<button id="button-1571-btnEl" class="x-btn-center" autocomplete="off" 
        role="button" hidefocus="true" type="button" style="height: 16px;">
  <span id="button-1571-btnInnerEl" class="x-btn-inner" style="margin: -1px 0px;" />
  <span id="button-1571-btnIconEl" class="x-btn-icon icon-plus" />
</button>

我试着只提供id,但它也不起作用,出现了错误,比如找不到匹配项谢谢matthias_h,这很有帮助//按钮[contains@class,'x-btn-center']/span[contains@class,'x-btn-icon-icon-icon-plus']/parent::button使用上述代码,我可以单击该按钮。
//div[@id='button-1571']/descendant::button[contains(@class, 'x-btn-center')]/
                     span[contains(@class,'x-btn-icon icon-plus')]/parent::button
<button id="button-1571-btnEl" class="x-btn-center" autocomplete="off" 
        role="button" hidefocus="true" type="button" style="height: 16px;">
  <span id="button-1571-btnInnerEl" class="x-btn-inner" style="margin: -1px 0px;" />
  <span id="button-1571-btnIconEl" class="x-btn-icon icon-plus" />
</button>