我目前正在学习硒。我尝试模拟来自 url“https://worldpopulationreview.com/countries/countries-by-gdp/#worldCountries”的 csv 文件的按钮单击。
我做了:
Right click the csv icon
Inspect and copy the full xpath
然后我使用了以下代码:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import os
driver = webdriver.Chrome()
url = 'https://worldpopulationreview.com/countries/countries-by-gdp'
driver.get(url)
xpath = '/html/body/div[1]/div/div[1]/div[2]/div[2]/div[1]/div/div/div/div[2]/div[1]/a[2]'
btn = driver.find_element_by_xpath(xpath)
btn.click()
# df = pd.read_csv(os.path.expanduser('~/Downloads/data.csv'))
# print(df.head())
# driver.close()
错误
WebDriverException: Message: unknown error: Element <a>...</a> is not clickable at point (1070, 879). Other element would receive the click: <div id="google_ads_iframe_/15184186/worldpopulationreview_adhesion_0__container__" style="border: 0pt none;">...</div>
(Session info: chrome=85.0.4183.121)
(Driver info: chromedriver=2.42.591059 (a3d9684d10d61aa0c45f6723b327283be1ebaad8),platform=Mac OS X 10.15.7 x86_64)
尝试
我尝试使用不同的 xpath 进行多次尝试,但没有成功。如何模拟该特定网站的按钮点击?
慕码人8056858
饮歌长啸
相关分类