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.

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

10 Comments

Thanks for your reply. I have to firebug installed but it is of no help This is what I get. <div class="rtbOuter"> <div class="rtbMiddle"> <div class="rtbInner"> <ul class="rtbUL"> <li class="rtbItem rtbBtn "> <li class="rtbItem rtbBtn"> <li class="rtbItem rtbBtn rtbItemFocused"> <a class=" rtbWrap" href="#"> <span class="rtbOut"> <span class="rtbMid"> <span class="rtbIn"> <img class="rtbIcon" src="/icons/16/app/shadow/document_add.png" alt=""> <span class="rtbText">New Article</span> </span> </span> </span> </a> </li> <li class="rt
Please check New Article is what I need to click on. Can i locate it some different way.
I am giving you from div it starts as there is limitation on text to be Enetered. <div> <div class="rtbOuter"> <div class="rtbMiddle"> <div class="rtbInner"> <ul class="rtbUL"> <li class="rtbItem rtbBtn "> <li class="rtbItem rtbBtn"> <li class="rtbItem rtbBtn rtbItemFocused"> <a class=" rtbWrap" href="#"> <span class="rtbOut"> <span class="rtbMid"> <span class="rtbIn"> <img class="rtbIcon" src="/icons/16/app/shadow/document_add.png" alt=""> <span class="rtbText">New Article</span> </span> </span> </span> </ul>
Thank you for your help. I Tried all of them Results are Unable to locate element: for all 3. I have to click on that New Article in order to get to next screen.
You can edit your question to add the entire source of your HTML page? Can you do that?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.