2016-09-27 65 views
0

我尝试从使用RSelenium的元素中提取href。Selenium找不到这样的元素

这里是HTML结构的一个例子:

<ol id="rem"> 
<div class="bare"> 
    <h3> 
     <a class="tlt mhead" href="https://www.myexample.com"> 

我用这个:

pro<-remDr$findElement(using = 'xpath', "//*/input[@class = 'bare']") 
    pro$highlightElement() 

但它无法找到元素,并返回该错误:

Error: Summary: NoSuchElement 
    Detail: An element could not be located on the page using the given search parameters. 
    class: org.openqa.selenium.NoSuchElementException 

我能做什么?

回答

0

不是input元素具有bare类中,div(假设dib是一个错字):

//div[@class='bare']/h3/a 
+0

谢谢。是的,它是div而不是dib。这似乎很合乎逻辑,但不幸的是我又收到了同样的错误。即使我尝试使用'pro <-remDr $ findElement(using ='xpath',“// */div [@ class ='bare']/h3/a”)',这可能会导致RSelenium – Elen

+0

中的语法不同一个问题,因为在这个结构的dom中有一个列表?所以我可以给位置,即[1] – Elen