我正在尝试使用Python在selenium和Chrome中登录到网站。我可以找到用户和密码字段以及按钮。我唯一不能做的就是用所有的字符串填充密码字段。它写一个子字符串,长度各不相同。Send_keys()不会发送完整的字符串
我的代码
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
browser=webdriver.Chrome(r"C:\Users\Visente\Desktop\Pablito Python\chromedriver.exe")
urlbet='https://www.bet365.es/?&cb=103265469#/HO/'
browser.get(urlbet)
sport=WebDriverWait(browser, 10).until(
EC.presence_of_element_located((By.XPATH,'//*[@id="dv1"]/a')))
sport.click()
user=WebDriverWait(browser,
10).until(EC.presence_of_element_located((
By.XPATH,'/html/body/div[1]/div/div[1]/div/div[1]/div[2]/div/div[1]/input')))
passw=browser.find_element_by_xpath(
'/html/body/div[1]/div/div[1]/div/div[1]/div[2]/div/div[2]/input[1]')
user.send_keys('my_user')
passw.send_keys('password')
submit=browser.find_element_by_xpath(
'/html/body/div[1]/div/div[1]/div/div[1]/div[2]/div/div[2]/button')`
submit.click()
因此,简而言之,对变量passw
其中y使用send_keys行()不写密码的全长和我不知道为什么。 顺便说一下,如何获取我刚刚用sed_keys()发送的文本,以便知道正在传递的内容以及字符串中缺少的内容?
你打算怎么做?请记住,在发送第一个字符后,x_path变长,以便在input [2] innstead of input [1] – puppet