0

Newbie in testing. I generated a test case using Selenium, and then exported it as a Python script. Now, when I try to run that in terminal, I get following error:

raise exception_class(message, screen, stacktrace)
NoSuchElementException: Message: u'Unable to locate element: {"method":"link                                                                                               
text","selector":"delete"}' 

I am using the command generated by Selenium i.e

driver.find_element_by_link_text("delete").click()

The reason for the error I believe is that the link "delete" in my web page is seen only when I click on a particular line to be deleted. So I guess it is being unable to locate the link. Please suggest what alternative measure could I use to locate and click on the "delete" link. Thanks in Advance:)

The Recruit
  • 803
  • 3
  • 9
  • 18
  • 1
    Have you tried other locators? Could you post the HTML of the element as well please? – Arran May 31 '12 at 12:28
  • Why don't you click on a line first and then click on delete? – A.J May 31 '12 at 13:19
  • @A.J Even though in Selenium we click the line and then delete it doesn't replicate the same in the script. thats where the entire problem arises and so does Job for testers..! – The Recruit May 31 '12 at 13:42
  • 1
    Have you tried using xpath to locate the element? This would at least rule out the possibility of a problem with your locator. – CIGuy May 31 '12 at 15:50
  • How would you find the xpath of that particular link which is highlighted only when you click the row it is present in..? Tried getting that from selenium but that does work as desired. :( – The Recruit Jun 01 '12 at 05:16
  • Without knowing the webpage you are testing it is hard to say, but you should be able to click the parent element, then wait for the delete element to be present and then click it. – CIGuy Jun 06 '12 at 15:21
  • @CIGuy IN practise and manually it works fine but I need to generate an automated test case script fot that.. Refer the comment to A.J. – The Recruit Jun 07 '12 at 06:10

1 Answers1

2

This may occur when selenium is trying to find the link while your application hasn't rendered it yet. So you need to make it wait until the link appears:

browser.implicitly_wait(10)

The answer which helped me is here.

Community
  • 1
  • 1
  • I understandthe concept of implicit wait but in my case that is not the prob. As I clearly stated it is NOT that the web page is taking time to render it. The "delete" link appears only when we click on particular line to be deleted. Anyways Thanks for your response. – The Recruit Jun 08 '12 at 12:28