Issue
I am working with the following selenium script:
from selenium import webdriver
PATH= r"C:\Users\Hamid\Desktop\Selenium\chromedriver.exe"
driver=webdriver.Chrome(PATH)
driver.get("https://www.google.com/")
cookie_button=driver.find_element_by_xpath('//*[@id="L2AGLb"]/div').click()
How do I add a command line to enter 'ONS data' onto the google search tab? Also, how can I turn the window into headless mode?
Solution
You can send the character sequence to the Google Search area using the following locator strategy:
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.NAME, "q"))).send_keys("ONS data")
Note: You have to add the following imports :
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
But once you have initiated google-chrome in headed mode you won't be able to shift to google-chrome-headless mode within the same session.
You can find a relevant detailed discussion in How can I switch from headless mode to normal mode using Google Chrome and Selenium?
Answered By - undetected Selenium
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.