问题
I am struggling with assigning a fix string value to be selected in a inspected search box using python but it's all in vein.
Please have a look in below image - here I want to choose the value automatically and get the create button clicked automatically:
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
from selenium import webdriver
from selenium.webdriver.common.by import By
#All the inspected fields
EMAILFIELD = (By.ID, "username")
PASSWORDFIELD = (By.ID, "password")
LOGINBUTTON = (By.ID, "Login")
CLICKBUTTON= (By.ID, "thePage:rtForm:createButton")
QUICKFINDSEARCH = (By.ID, "quickFindInput")
browser = webdriver.Chrome(
executable_path=r"C:/Users/RYadav/AppData/Roaming/Microsoft/Windows/Start Menu/Programs/Python 3.8/chromedriver.exe")
browser.get('https://fleet.my.salesforce.com/')
# wait for email field and enter email
WebDriverWait(browser, 5).until(EC.element_to_be_clickable(EMAILFIELD)).send_keys("xyz@element.com")
# wait for password field and enter password
WebDriverWait(browser, 5).until(EC.element_to_be_clickable(PASSWORDFIELD)).send_keys("Happy@1234")
# Click Login - same id?
WebDriverWait(browser, 5).until(EC.element_to_be_clickable(LOGINBUTTON)).click()
#this is the code block I am directing to after hitting on the url shown in the image
browser.get('https://fleet.my.salesforce.com/reportbuilder/reportType.apexp')
for i in QUICKFINDSEARCH == ('users'):
#click on Create Button
WebDriverWait(browser, 5).until(EC.element_to_be_clickable(CLICKBUTTON)).click()
来源:https://stackoverflow.com/questions/62212088/how-to-assign-a-specific-string-value-in-search-box-to-get-this-hit-entered-blin