2016-11-18 92 views
0

我试图单击此页中使用硒的webdriver在Python 3中的链接:使用Python +硒点击雅虎财经的链接

https://finance.yahoo.com/quote/GOOG?ltr=1

url = 'https://finance.yahoo.com/quote/GOOG?ltr=1' 
display = Display(visible=0,size=(600,800)) 
display.start() 
driver = webdriver.Firefox() 
driver.get(url) 
driver.find_element_by_link_text('Statistics') 

上面的代码没有按不能使用显示的两行,并且抛出关于无法点击元素的错误。但是,如果我将它们评论出来,它确实有用。

+1

可能的重复http://stackoverflow.com/questions/20485360/selenium-with-pyvirtualdisplay-unable-to-locate-element –

回答

0

我已经想通了,为什么它不工作。显示器尺寸(600,800)太小。一旦我将大小设置为监视器允许的最大值,然后找到元素。

1

那么,你的网址不包含在引号中。我敢打赌,这是你的问题。

变化

url = https://finance.yahoo.com/quote/GOOG?ltr=1 

url = "https://finance.yahoo.com/quote/GOOG?ltr=1" 
+0

实际上这是我的一个错字。我已经纠正它。 – AppleCider