python - Selenium 地理定位测试
问题描述
在 selenium 上尝试此功能。我们是否需要与元素交互来设置所需的地理位置?到目前为止,这似乎对位置没有任何影响,因此需要进行一些澄清。
chrome_options = Options()
params = {
"latitude": 50.1109,
"longitude": 8.6821,
"accuracy": 100
}
driver = webdriver.Chrome(executable_path='C:/chromedriver.exe', options=chrome_options)
driver.execute_cdp_cmd("Page.setGeolocationOverride", params)
driver.get("https://www.yellowpages.com/")
time.sleep(5)
例如,它适用于该站点,但在单击 geolocate 元素之后。那么,我们在网站上找到了这个元素吗?如果网站没有这样的地理定位元素怎么办?
driver.get("https://locations.dennys.com/search.html/")
time.sleep(10)
location_icon = driver.find_element_by_css_selector(".icon-geolocate")
time.sleep(10)
location_icon.click()
解决方案
推荐阅读
- javascript - 丢弃功能不起作用
- sql - 如何在 SQL 中将查询组拆分为频率/出现次数
- python - Django2 - 自动为注册用户分配一定数量的加密货币
- excel - Excel 使用单元格引用作为具有多个条件的逻辑运算符并查找值
- hbase - 使用 HBase 时,是否可以将分区数据存储在从节点的主内存中,如 IMDB(内存数据库)?
- javascript - RxJS - concatenate mapped elements onto a stream
- reactjs - 反应路由,路径不起作用,找不到捆绑包
- django - 性能:在 Postgresql ArrayField 中存储喜欢(django 示例)
- r - 如何以一种不错的方式显示列表列表
- go - 在 Golang 中传递 interface{} 或 []interface{}