简体   繁体   English

如何在 html 头中找到标题名称为 XPATH 的标题

[英]How to locate title in html head with the title name XPATH

i am trying locate title in html head with the title name XPATH.我正在尝试在 html 头中定位标题,标题名称为 XPATH。

i have tried below xpaths but no luck/我在 xpaths 下尝试过,但没有运气/

i) //contains[@title='Demo Script Test drive - PHPTRAVELS'] ii) //head[@title='Demo Script Test drive - PHPTRAVELS'] i) //contains[@title='Demo Script Test drive - PHPTRAVELS'] ii) //head[@title='Demo Script Test drive - PHPTRAVELS']

i don't want full xpaths我不想要完整的 xpath

please refer below image as well as this link-请参考下图以及此链接-

https://phptravels.com/demo https://phptravels.com/demo

在此处输入图像描述

You can use the below xpath:您可以使用以下 xpath:

//title

there are 4 nodes in HTML-DOM , however if you use //title in driver.find_element(By.XPATH, "//title") command, it would point to the first node. HTML-DOM中有4 nodes ,但是如果在driver.find_element(By.XPATH, "//title")命令中使用//title ,它将指向第一个节点。

Also, you could try the below xpath:此外,您可以尝试以下 xpath:

//title[text()='Demo Script Test drive - PHPTRAVELS']

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM