英文:
My goal is to click on the view details button after searching for the persons name
问题
Whenever the search button is pressed, the webpage generates a new instance; however, my program is not reading the new instance, so it is not finding the correct "//a[@herf]".
def ClientInformation():
# CI = textbox.get('1.0', END)
CI = "first name, Last Name"
city = "City, State"
options = Options()
options.add_experimental_option("detach", True)
# Installs and Opens Chrome to "Truepeoplesearch.com"
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()),
options=options)
driver.get("https://www.truepeoplesearch.com/")
# Enters data from UI to text fields and searches
driver.find_element(by="name", value="CityStateZip").send_keys(city)
driver.find_element(by="name", value="Name").send_keys(CI)
if len(driver.find_elements("xpath", "//a[@herf]")) > 0:
driver.find_elements("xpath","//a[@herf]")[0].click()
else:
print("you suck")
It always prints "you suck"
^^^^^^^ Doesn't work as well as I intended vvvvvvvvvvv new iteration
solved
CI = textbox.get('1.0', END)
# Split Client Information by " : "
CIS = re.split(r' ', str(CI))
FN = CIS[0]
LN = CIS[1]
CT = CIS[2]
ST = CIS[3]
driver.get("https://www.truepeoplesearch.com/results?name=" + FN + "%20" + LN +"&citystatezip= " + CT + " %20" + ST + "")
英文:
Whenever the search button is pressed the webpage generates a new instance however my program is not reading the new instance so it is not finding the correct "//a[@herf]".
def ClientInformation():
#CI = textbox.get('1.0', END)
CI = "first name, Last Name"
city = "City, State"
options = Options()
options.add_experimental_option("detach", True)
#Installs and Opens Chrome to "Truepeoplesearch.com"
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()),
options=options)
driver.get("https://www.truepeoplesearch.com/")
#Enters data from UI to text fields and searches
driver.find_element(by="name", value="CityStateZip").send_keys(city)
driver.find_element(by="name", value="Name").send_keys(CI)
if len(driver.find_elements("xpath", "//a[@herf]")) > 0:
driver.find_elements("xpath","//a[@herf]")[0].click()
else:
print("you suck")
It always prints you suck
^^^^^^^ Doesn't work as well as I intended vvvvvvvvvvv new iteration
solved
CI = textbox.get('1.0', END)
#Split Client Information by " : "
CIS = re.split(r' ', str(CI))
FN = CIS[0]
LN = CIS[1]
CT = CIS[2]
ST = CIS[3]
driver.get("https://www.truepeoplesearch.com/results?name=" + FN + "%20" + LN +"&citystatezip= " + CT + " %20" + ST + "")
答案1
得分: 1
The site is blocking me so I can't test your script, but I would guess that you have a typo in there, and ("xpath","//a[@herf]")
should instead read ("xpath","//a[@href]")
.
英文:
The site is blocking me so I can't test your script, but I would guess that you have a typo in there, and ("xpath","//a[@herf]")
should instead read ("xpath","//a[@href]")
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论