[英]How to get meta tag content value in Watir?
I'am not able to get the content value of meta tag from site in Ruby using Watir-webdriver gem. 我无法使用Watir-webdriver gem从Ruby中的站点获取meta标签的内容值。
eg 例如
<meta property="og:title" content="【楽天市場】ダヴ メンプラスケア クリーンコンフォート泡洗顔 つめかえ用(110mL)【unili3e102】【ダヴ(Dove)】[ダヴ 洗顔]:爽快ドラッグ">
The problem with browser.meta(:property, 'og:title').content
is that "property" is not a valid attribute for meta tags. browser.meta(:property, 'og:title').content
的问题在于“ property”不是元标记的有效属性。 As a result, Watir does not allow it as a locator method. 结果,Watir不允许将其作为定位器方法。
To locate elements via unsupported attributes, you will need to use a CSS-selector: 要通过不受支持的属性来定位元素,您将需要使用CSS选择器:
browser.meta(css: 'meta[property="og:title"]').content
Or use XPath: 或使用XPath:
browser.meta(xpath: '//meta[@property="og:title"]').content
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.