如何在點擊元素後使用硒查找當前網址。我有這樣的網站:http://www.runningintheusa.com/Classic/View.aspx?RaceID=5622單擊鏈接後查找URL
我的代碼(假設所有相關庫進口)
def get_detail(x):
dic = {}
driver = webdriver.PhantomJS(path)
driver.get(x)
driver.find_element_by_id('ctl00_ctl00_MainContent_hypPrimaryURL').click()
return driver.current_url
print get_detail('http://www.runningintheusa.com/Classic/View.aspx?RaceID=5622')
我跑的代碼,它只能回到原來的網址是http://www.runningintheusa.com/Classic/View.aspx?RaceID=5622
哪有我點擊網站上的競賽網站鏈接後找到網址http://flagstaffbigs.org/dave-mckay-run.htm
的可能的複製[硒等到文檔準備就緒(https://stackoverflow.com/questions/15122864/selenium-wait-until-document-is-ready) – Anthon
@Anthon我試圖把時間。睡覺(2)但它沒有工作 –
爲什麼2秒就夠了? – Anthon