3

The following code won't terminate. What could be the reason for that?

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Firefox()
driver.get("http://www.quora.com/physics")
elem = driver.find_element_by_class_name("cancel")

#ele=elem[0]

print "done"
2
  • The problem probably is that the element is in quora.com/physics# while i try to search it in quora.com/physics. But i am not able to find any alternative. Any suggestions/explanations? Commented May 16, 2013 at 6:32
  • What is the last action that selenium does before stopping to respond? Commented Nov 7, 2013 at 22:59

1 Answer 1

1

Try Using linkText instead of className. It is working when i tried.

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Firefox()
driver.get("http://www.quora.com/physics")
elem = driver.find_element_by_link_text("Close & Read Quora")

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

1 Comment

This worked for me too, it just takes a very long time, like a few minutes, to find the element for some reason

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.