[英]JavaScript: How we can call Document.evaluate method for getting result
我正在使用下面的代碼來獲取結果值,但是執行該代碼時會顯示一條錯誤消息。 ( Failed to read the 'numberValue' property from 'XPathResult': The result type is not a number.
)
請看一下以獲取價值。
IJavaScriptExecutor js = (IJavaScriptExecutor)driver;
var confirmationtext = "return document.evaluate( \"//*[@id='main-content']/div/div/div/h2/strong\", document, null, XPathResult.STRING_TYPE, null)";
var returnvalue = js.ExecuteScript(confirmationtext);
您正在使用STRING_TYPE
。 如果您確定始終是數字或ANY_TYPE
,請嘗試使用NUMBER_TYPE
,但我不建議這樣做。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.