首页 > 其他分享 >一、输入注册用户名字及获取用户信息-8

一、输入注册用户名字及获取用户信息-8

时间:2022-08-26 15:58:50浏览次数:50  
标签:webdriver selenium driver 用户 element email 注册 find 输入

1、判断设想的输入信息,和真实输入的信息是否相同。

  • 考虑email
  • 获取元素的注释信息get_attribute("placeholder")
  • 给该元素输入一个值为[email protected]
  • 获取输入的值get_attribute("value")
#coding=utf-8
from selenium import webdriver
import time
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.common.by import By

driver = webdriver.Chrome()
#driver = webdriver.Firefox()
#driver = webdriver.Edge()

driver.get("http://www.5itest.cn/register")
time.sleep(5)
print(EC.title_contains("注册"))

#element = driver.find_element_by_class_name("controls")
localor = (By.CLASS_NAME,"controls")
WebDriverWait(driver,10).until(EC.visibility_of_element_located(localor))
email_element = driver.find_element_by_id("register_email") print(email_element.get_attribute("placeholder")) email_element.send_keys("[email protected]") print(email_element.get_attribute("value")) driver.close() #driver.find_element_by_id("register_email").send_keys("[email protected]") #user_name_element_node = driver.find_elements_by_class_name("controls")[1] #user_element = user_name_element_node.find_element_by_class_name("form-control") #user_element.send_keys("zhangjieqiong") #driver.find_element_by_name("password").send_keys("zjq111111") #driver.find_element_by_xpath("//*[@id='captcha_code']").send_keys("11111")

 

PS D:\imooc\selenium> python .\start_browser.py

DevTools listening on ws://127.0.0.1:58496/devtools/browser/cfaf1e74-4607-4335-ac83-d4ae538337d9       
<selenium.webdriver.support.expected_conditions.title_contains object at 0x000002445FCB06D8>
填写你常用的邮箱作为登录帐号
[email protected]
PS D:\imooc\selenium>

 

标签:webdriver,selenium,driver,用户,element,email,注册,find,输入
From: https://www.cnblogs.com/jieqiong1755/p/16627767.html

相关文章