【问题标题】:Can't get selenium python to click the submit button on google maps无法让 selenium python 单击谷歌地图上的提交按钮
【发布时间】:2020-12-17 01:12:39
【问题描述】:

无法让 selenium python 点击​​谷歌地图上的提交按钮。我已经能够让它在谷歌地图搜索栏中输入文本,但就是这样。

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
import time

PATH = "C:\Program Files (x86)\chromedriver.exe"
driver = webdriver.Chrome(PATH)

driver.get("https://www.google.com/maps/")

inputboxes = driver.find_elements(By.CLASS_NAME, 'text_field')
driver.find_element(By.ID, 'searchboxinput').send_keys("byu store")

element = WebDriverWait(driver, 10).until(
    driver.find_element((By.ID, "searchbox-searchbutton"))
)
element.click()

这部分不起作用。

element = WebDriverWait(driver, 10).until(
    driver.find_element((By.ID, "searchbox-searchbutton"))
)
element.click()

【问题讨论】:

    标签: javascript python selenium


    【解决方案1】:

    使用以下命令点击搜索按钮。

    element = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "searchbox-searchbutton")))
    element.click()
    

    导入

    from selenium.webdriver.support.ui import WebDriverWait 
    from selenium.webdriver.support import expected_conditions as EC
    

    你之前的代码有一个

    selenium.common.exceptions.InvalidArgumentException: Message: invalid argument: 'using' must be a string
    

    【讨论】:

    • 好像没有提交。
    • 好吧,你说得对,我只导入了你建议的两件事中的一件。现在它起作用了。感谢您的帮助!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-01-15
    • 2020-07-30
    • 1970-01-01
    • 1970-01-01
    • 2021-03-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多