Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Push Button on website
#2
Most first push accept all button.
Then input some text and search.
Code is old,have to setup chrome driver(in a OS path) first in code.
Old way find_element_by_xpath new find_element(By.XPATH, 'tag').
Here a working test.
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
import time

# Setup
#https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/121.0.6154.0/win64/chromedriver-win64.zip"
options = Options()
#options.add_argument("--headless=new")
ser = Service(r"C:\cmder\bin\chromedriver.exe")
browser = webdriver.Chrome(service=ser, options=options)
# Parse or automation
url = "https://www.google.com/"
browser.get(url)
time.sleep(3)
accept_bt = browser.find_element(By.CSS_SELECTOR, '#L2AGLb')
accept_bt.click()
input_field = browser.find_element(By.CSS_SELECTOR, '#APjFqb')
input_field.send_keys('car')
time.sleep(3)
search_bt = browser.find_element(By.XPATH, 'input.gNO89b')
search_bt.click()
Reply


Messages In This Thread
Push Button on website - by cg1980 - Feb-05-2024, 03:38 PM
RE: Push Button on website - by snippsat - Feb-07-2024, 01:25 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Login and download an exported csv file within a ribbon/button in a website Alekhya 0 2,771 Feb-26-2021, 04:15 PM
Last Post: Alekhya
  Automated Git add/commit/push rxndy 0 2,128 May-13-2019, 11:51 AM
Last Post: rxndy
  data push from logger to server asdfasdf 2 3,798 May-02-2017, 11:32 AM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020