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"
blitz19
  • 33
  • 5
  • The problem probably is that the element is in http://www.quora.com/physics# while i try to search it in http://www.quora.com/physics. But i am not able to find any alternative. Any suggestions/explanations? – blitz19 May 16 '13 at 06:32
  • What is the last action that selenium does before stopping to respond? – Zeinab Abbasimazar Nov 07 '13 at 22:59

1 Answers1

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"
HemChe
  • 2,249
  • 1
  • 21
  • 33
  • This worked for me too, it just takes a very long time, like a few minutes, to find the element for some reason – qwwqwwq May 16 '13 at 22:05