0

Selenium Webdriver. Looking to Locate New Article from following code. Please note this is under an iframe.

<img class="rtbIcon" src="/icons/16/app/shadow/document_add.png" alt="">
                                 <span class="rtbText">New Article</span>

I have tried to locate with xpath and many other ways. But following is what I get everytime

Code : driver.findElement(By.xpath("id('RadToolBar1'):div:div:div:ul:li[3]:a:span:span:span:span"));

Result: The given selector id('RadToolBar1'):div:div:div:ul:li[3]:a:span:span:span:span is either invalid or does not result in a WebElement. The following error occurred:

New article has no name, id so please if some one can help find me solution.

Prasad
  • 472
  • 5
  • 15
Sagar Yadav
  • 1
  • 1
  • 1

1 Answers1

1

Your xpath seems to be wrong. The best way to get the xpath for any element on a page is by installing mozilla add on - Fire Bug. You can inspect any element using this add on and also copy the correct xpath of your element present on the page.

This should be your xpath -

driver.findElement(By.xpath("//*[@class='rtbText']"));

or

driver.findElement(By.linkText("New Article"));

One of these should work. Let me know if you face any problem.

Hari Reddy
  • 3,808
  • 4
  • 33
  • 42