简体   繁体   中英

Can't get selenium python to click the submit button on google maps

Can't get selenium python to click the submit button on google maps. I have been able to make it input text into the google maps search bar but that's it.

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()

This part doesn't work.

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

Use the following to click the search button.

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

Import

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

Your previous code had a

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM