RSelenium 弹出 window
RSelenium Pop up window
我正在尝试在 HTML 页面中打开弹出窗口 link:
<a class="popup-link" href="/PPI/displayRemarks.do?itemId=100582281" title="Add Remarks for the item" onclick="return false" id="anch_12">Add remarks</a>
我尝试使用 ID 查找元素:
remDr$findElement(using = 'id', "anch_12")
我收到此错误:
Selenium message:{"errorMessage":"Unable to find element with id 'anch_12'","request":{"headers":{"Accept":"application/json, text/xml, application/xml, /","Accept-Encoding":"gzip, deflate","Content-Length":"32","Content-Type":"application/json","Host":"localhost:4567","User-Agent":"libcurl/7.56.0 r-curl/3.0 httr/1.3.1"},"httpVersion":"1.1","method":"POST","post":"{\"using\":\"id\",\"value\":\"anch_12\"}","url":"/element","urlParsed":{"anchor":"","query":"","file":"element","directory":"/","path":"/element","relative":"/element","port":"","host":"","password":"","user":"","userInfo":"","authority":"","protocol":"","source":"/element","queryKey":{},"chunks":["element"]},"urlOriginal":"/session/c6eac2b0-1bfd-11e8-8fbd-fbf94221e6d1/element"}}
错误摘要:
NoSuchElement Detail: An element could not be located on the page using the given search parameters. class: org.openqa.selenium.NoSuchElementException Further Details: run errorDetails method
id
anch_12 以及值为 itemId=100582281[=18 的 href
属性=] 看起来很动态。因此你必须构建一个动态的 xpath
如下:
remDr$findElement(using = 'xpath', "//a[@class='popup-link' and contains(@href,'/PPI/displayRemarks.do?itemId=') and starts-with(@id,'anch_')]")
//or
remDr$findElement(using = 'xpath', "//a[@class='popup-link' and contains(@title,'Add Remarks for the item') and starts-with(@id,'anch_')]")
我正在尝试在 HTML 页面中打开弹出窗口 link:
<a class="popup-link" href="/PPI/displayRemarks.do?itemId=100582281" title="Add Remarks for the item" onclick="return false" id="anch_12">Add remarks</a>
我尝试使用 ID 查找元素:
remDr$findElement(using = 'id', "anch_12")
我收到此错误:
Selenium message:{"errorMessage":"Unable to find element with id 'anch_12'","request":{"headers":{"Accept":"application/json, text/xml, application/xml, /","Accept-Encoding":"gzip, deflate","Content-Length":"32","Content-Type":"application/json","Host":"localhost:4567","User-Agent":"libcurl/7.56.0 r-curl/3.0 httr/1.3.1"},"httpVersion":"1.1","method":"POST","post":"{\"using\":\"id\",\"value\":\"anch_12\"}","url":"/element","urlParsed":{"anchor":"","query":"","file":"element","directory":"/","path":"/element","relative":"/element","port":"","host":"","password":"","user":"","userInfo":"","authority":"","protocol":"","source":"/element","queryKey":{},"chunks":["element"]},"urlOriginal":"/session/c6eac2b0-1bfd-11e8-8fbd-fbf94221e6d1/element"}}
错误摘要:
NoSuchElement Detail: An element could not be located on the page using the given search parameters. class: org.openqa.selenium.NoSuchElementException Further Details: run errorDetails method
id
anch_12 以及值为 itemId=100582281[=18 的 href
属性=] 看起来很动态。因此你必须构建一个动态的 xpath
如下:
remDr$findElement(using = 'xpath', "//a[@class='popup-link' and contains(@href,'/PPI/displayRemarks.do?itemId=') and starts-with(@id,'anch_')]")
//or
remDr$findElement(using = 'xpath', "//a[@class='popup-link' and contains(@title,'Add Remarks for the item') and starts-with(@id,'anch_')]")