Пример #1
0
 def Login(self,driver):
     username=driver.find_element_by_xpath("//input[@class='W_input' and @node-type='username']")
     sleep(5)
     username.send_keys('*****@*****.**')
     password=driver.find_element_by_xpath("//input[@class='W_input' and @node-type='password']")
     password.send_keys(encrypt('b\jT\i325'))
     sleep(5)
     driver.find_element_by_xpath("//div[@class='info_header']/following-sibling::div[1]/div[6]//span").click()
Пример #2
0
from selenium import webdriver
from com.sina.jiami import encrypt
from time import *
driver=webdriver.Firefox()
driver.get('http://mail.163.com/')
sleep(5)
print driver.title
sleep(2)
print driver.current_url
sleep(2)
name=driver.find_element_by_id('idPlaceholder')
sleep(2)
name.send_keys('gaoli152027')
password=driver.find_element_by_id('pwdPlaceholder')
sleep(2)
password.send_keys(encrypt('b\jt\i325'))
driver.find_element_by_id('loginBtn').click()
sleep(3)
print driver.title
sleep(3)
print driver.current_url
sleep(2)
usename=driver.find_element_by_id('spnUid').text
print usename
listname=['*****@*****.**']
try:
    if usename in listname:
        print 'true,testcase is successful!'
    else:
        print 'false,testcase is fail!!!'
Пример #3
0
        self.driver.get('http://www.weibo.com/')
        self.driver.maximize_window()
        self.driver.implicitly_wait(30)
        self.username=username
        self.password=password
        sleep(5)
def do_login_as(driver,user_info):
    username=driver.find_element_by_xpath("//input[@class='W_input' and @node-type='username']")
    username.send_keys(user_info.username)
    password=driver.find_element_by_xpath("//input[@class='W_input' and @node-type='password']")
    password.send_keys(user_info.password)
    sleep(5)
    driver.find_element_by_xpath("//div[@class='info_header']/following-sibling::div[1]/div[6]//span").click()
def do_logout_as(driver):
    sleep(10)
    driver.find_element_by_xpath("//em[text()='*']").click()
    sleep(5)
    driver.find_element_by_xpath(u"//a[text()='退出']").click()
    sleep(3)
    driver.quit()
if __name__=='__main__':
        
    #实例化登陆信息
    admin1=Account(username='******',password=encrypt('b\jT\i325'))
    #admin2=Account(username='******',password='******')
    #调用函数登陆
    driver=admin1.driver
    do_login_as(driver,admin1)
    do_logout_as(driver)
    #do_login_as(admin2)
Пример #4
0
import sys

sys.path.append("D:\116460\workspace\WYexercise\src\com\exercise\wangyi")
from com.sina import jiami
from selenium.webdriver.common.action_chains import ActionChains

driver = webdriver.Firefox()
driver.get("http://pan.baidu.com/")
driver.implicitly_wait(20)
name = driver.find_element_by_id("TANGRAM__PSP_4__userName")
sleep(2)
name.clear()
name.send_keys(u"牵着蚂蚁溜11")
password = driver.find_element_by_id("TANGRAM__PSP_4__password")
sleep(2)
password.clear()
password.send_keys(jiami.encrypt("b\jt\i325"))
driver.find_element_by_id("TANGRAM__PSP_4__submit").click()
sleep(5)
driver.maximize_window()
sleep(2)
# driver.find_element_by_xpath("//em[class='app-icon i-disk']").click()
# sleep(2)
driver.refresh()
sleep(10)
lastceng = driver.find_element_by_xpath("//div[@class='list']/div[last()]")
ActionChains(driver).move_to_element_with_offset(lastceng, 100, 100).perform()
print 123
sleep(5)
driver.close()
Пример #5
0
driver.get('http://www.weibo.com/')
sleep(5)
user_file=open('myuserfile.txt','r')
values=user_file.readlines()
user_file.close()

print values
#结果以列表的形式返回
print type(values)

for i in values: 
    sleep(5)
    user=driver.find_element_by_xpath("//input[@class='W_input' and @node-type='username']")
    user.send_keys(i.split(';')[0])
    password1=driver.find_element_by_xpath("//input[@class='W_input' and @node-type='password']")
    password1.send_keys(encrypt(i.split(';')[1]))
    print(i.split(';')[0],'==>',encrypt(i.split(';')[1]))
    sleep(2) 
    button1= WebDriverWait(driver,10,2).until(EC.presence_of_element_located((By.XPATH,"//div[@class='info_header']/following-sibling::div[1]/div[6]//span")))
    button1.click()
    sleep(2)
    result=ElementExist(driver,"//span[text()='用户名或密码错误。']")
    print(result)
    if result:
        break
    else:
        print(result)
        driver.refresh()
        sleep(5)
        continue
sleep(5)    
Пример #6
0
#coding=utf-8
from selenium import webdriver
from com.sina.jiami import encrypt
from mydef4 import Logiout
from time import *
driver=webdriver.Firefox()
driver.get('http://www.weibo.com/')
sleep(5)
Logiout(driver).Login('*****@*****.**',encrypt('b\jT\i325'))
sleep(5)
Logiout(driver).Loginout()