我已经设法写了一个程序,可以导航到所需的网站,并点击第一个文本框,我想填写。我遇到的问题是,我使用的send\u keys方法没有用“Testing”填充所需的文本框,我收到了以下错误:
AttributeError: 'NoneType' object has no attribute 'find_elements_by_xpath'
以下是迄今为止的代码:
import selenium
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait as Wait
from selenium.webdriver.support import expected_conditions
driver = selenium.webdriver.Chrome(executable_path='path_to_chromedriver')
def get_url(url):
driver.get(url)
driver.maximize_window()
Wait(driver, 30).until(expected_conditions.presence_of_element_located
((By.ID, 'signup-button'))).click()
def fill_data():
sign_up = Wait(driver, 30).until(expected_conditions.presence_of_element_located
((By.XPATH,
'/html/body/onereg-app/div/onereg-form/div/div/form/section/section['
'1]/onereg-alias-check/ '
'fieldset/onereg-progress-meter/div[2]/div[2]/div/pos-input[1]'))).click()
sign_up.send_keys('Testing')
get_url('https://www.mail.com/')
# Find the signup element
fill_data()
find \u elements \u by \u xpath`返回所有匹配的元素,这是一个列表,因此需要循环并获取每个元素的text属性
另外,在fill data方法中,您尝试为注册表单填充数据,因此需要标识该表单上的所有元素,并使用表单和数据进行处理
填写电子邮件Id时xpath不正确,请更新xpath并重试
相关问题 更多 >
编程相关推荐