如何使用 Xpath 获取下面 HTML 中的 P 标记?谢谢
How do I get to P tag in the below HTML using Xpath ? Thanks
I want to assert **"sorry you cant Sorry, you do not have access the to the requested page** but I am not able to reach there..
我可以到这里:
//*[@id="page"]/child::div/following-sibling::section/
我该如何继续?下面是我的代码:
> <section id="page" class="same-as-sidebar ng-scope" ng-class="{
> 'hide-mainnav' : (Engine.hideMainNav == true),
> 'not-loaded': (!Engine.readyAnimate == true)
> }" ui-view="content" style="">
> <div class="main ng-scope">
> <!-- uiView: content --><section ui-view="content" class="ng-scope">
> <div class="main ng-scope">
> <!-- uiView: content --><section ui-view="content" class="ng-scope">
> <div class="row ng-scope">
> <div class="col-md-12">
> <h1 style="
> font-weight:bold;
> font-size:0px;
> width:100%;
> text-align:center;
> color:black;
> ">
> 404
> </h1>
> <img style="max-width:400px;margin:20px auto;display:block;" alt="404"
> src="/1124px-NL_Route_404.svg.png">
>
> <p style="margin:20px auto;width:100%;display:block;text-align:center;">Sorry, you do not
> have access the to the requested page</p>
> <div class="row">
查找带有@id-attribute 的元素总是好的。它们应该是唯一的,并且 XPath 引擎可能会最快地找到它们。所以这是橡木味的。
由于我假设 div 的顺序和数量各不相同,并且在本示例中呈现的部分似乎没有关闭,所以我将使用此 XPath:
//*[@id="page"]//p[text()='Sorry, you do not have access the to the requested page']
I want to assert **"sorry you cant Sorry, you do not have access the to the requested page** but I am not able to reach there..
我可以到这里: //*[@id="page"]/child::div/following-sibling::section/
我该如何继续?下面是我的代码:
> <section id="page" class="same-as-sidebar ng-scope" ng-class="{
> 'hide-mainnav' : (Engine.hideMainNav == true),
> 'not-loaded': (!Engine.readyAnimate == true)
> }" ui-view="content" style="">
> <div class="main ng-scope">
> <!-- uiView: content --><section ui-view="content" class="ng-scope">
> <div class="main ng-scope">
> <!-- uiView: content --><section ui-view="content" class="ng-scope">
> <div class="row ng-scope">
> <div class="col-md-12">
> <h1 style="
> font-weight:bold;
> font-size:0px;
> width:100%;
> text-align:center;
> color:black;
> ">
> 404
> </h1>
> <img style="max-width:400px;margin:20px auto;display:block;" alt="404"
> src="/1124px-NL_Route_404.svg.png">
>
> <p style="margin:20px auto;width:100%;display:block;text-align:center;">Sorry, you do not
> have access the to the requested page</p>
> <div class="row">
查找带有@id-attribute 的元素总是好的。它们应该是唯一的,并且 XPath 引擎可能会最快地找到它们。所以这是橡木味的。
由于我假设 div 的顺序和数量各不相同,并且在本示例中呈现的部分似乎没有关闭,所以我将使用此 XPath:
//*[@id="page"]//p[text()='Sorry, you do not have access the to the requested page']