关于Java:请为以下HTML建议正确的xpath

Please suggest the correct xpath for the below HTML

1
<span class="glyphicon glyphicon-remove" title="Close"></span><span class="glyphicon glyphicon-pause" title="Stick"></span><span class="glyphicon glyphicon-question-sign"></span><h4 class="ui-pnotify-title">Confirmation Needed</h4>You are currently logged in from another browser.Are you sure to log-off the other session?<button type="button" class="btn btn-default">Ok</button> <button type="button" class="btn btn-default">Cancel</button>

我需要单击确定


这可能会有所帮助:

  • 在这种情况下,请使用xPath。
  • 为此使用google chrome的内置开发人员工具
  • 将光标放在元素上
  • 按Ctrl Shift C
  • 单击元素
  • 单击的元素的代码在底部的短窗口中突出显示
  • 右键单击突出显示的代码
  • 选择复制>复制XPath
  • 在这里,您已经为该特定元素复制了xPath。如图所示:

    单击以查看如何复制xPath

    参考:Selenium命令


    我将使用以下内容确定并取消。这是偶然出现在弹出式iframe中吗?

    1
    2
     //button[contains(text(), 'Ok')]
     //button[contains(text(), 'Cancel')]

    1
    "//div[@class='alert ui-pnotify-container alert-warning ui-pnotify-shadow']//button[.='Ok']"