def login(): driver.find_element_by_id('com.tal.kaoyan:id/login_email_edittext').clear() driver.find_element_by_id( 'com.tal.kaoyan:id/login_email_edittext').send_keys('自学网2018') driver.find_element_by_id( 'com.tal.kaoyan:id/login_password_edittext').send_keys('zxw2018') driver.find_element_by_id('com.tal.kaoyan:id/login_login_btn').click()
def login(): driver.find_element_by_id("com.tal.kaoyan:id/login_email_edittext").clear() driver.find_element_by_id( "com.tal.kaoyan:id/login_email_edittext").send_keys("自学网2018") driver.find_element_by_id( "com.tal.kaoyan:id/login_password_edittext").send_keys("zxw2018") driver.find_element_by_id("com.tal.kaoyan:id/login_login_btn").click()
from find_element.capability import driver driver.find_element_by_id('com.tal.kaoyan:id/login_register_text').click() driver.find_element_by_id('com.tal.kaoyan:id/activity_register_userheader').click() images=driver.find_elements_by_id('com.tal.kaoyan:id/item_image') images[10].click() driver.find_element_by_id('com.tal.kaoyan:id/save').click()
from find_element.capability import driver import random driver.find_element_by_id('com.tal.kaoyan:id/login_register_text').click() #头像设置 driver.find_element_by_id('com.tal.kaoyan:id/activity_register_userheader').click() images=driver.find_elements_by_id('com.tal.kaoyan:id/item_image') images[10].click() driver.find_element_by_id('com.tal.kaoyan:id/save').click() #用户名密码邮箱信息填写 username='******'+'FLY'+str(random.randint(1000,9000)) print('username: %s' %username) driver.find_element_by_id('com.tal.kaoyan:id/activity_register_username_edittext').send_keys(username) password='******'+str(random.randint(1000,9000)) print('password: %s' %password) driver.find_element_by_id('com.tal.kaoyan:id/activity_register_password_edittext').send_keys(password) email='51zxw'+str(random.randint(1000,9000))+'@163.com' print('email: %s' %email) driver.find_element_by_id('com.tal.kaoyan:id/activity_register_email_edittext').send_keys(email) driver.find_element_by_id('com.tal.kaoyan:id/activity_register_register_btn').click() #院校选择 driver.find_element_by_id('com.tal.kaoyan:id/perfectinfomation_edit_school_name').click() driver.find_elements_by_id('com.tal.kaoyan:id/more_forum_title')[1].click() driver.find_elements_by_id('com.tal.kaoyan:id/university_search_item_name')[1].click()
#! /usr/bin/env/python # -*- coding:utf-8 -*- from find_element.capability import driver from selenium.webdriver.support.ui import WebDriverWait # 登录email: com.multilotto.lottery:id/ev_log_in_email root_email = driver.find_element_by_id('com.multilotto.lottery:id/ev_log_in_email') email_edit = root_email.find_element_by_class_name('android.widget.EditText') # id com.multilotto.lottery:id/ev email_edit.clear() email_edit.send_keys('*****@*****.**') # 密码元素 root_password = driver.find_element_by_id('com.multilotto.lottery:id/ev_log_in_password') # password_edit = root_password.find_element_by_name('Password') #失败了 password_edit = root_password.find_element_by_id('com.multilotto.lottery:id/ev') # id com.multilotto.lottery:id/ev password_edit.send_keys('Aa123456') driver.find_element_by_id('com.multilotto.lottery:id/btn_login').click() error_message="用户名或密码错误,还可以尝试四次" limit_message="验证失败次数过多,请15分钟后再试" message='//*[@text=\'{}\']'.format(error_message) # message='//*[@text=\'{}\']'.format(limit_message) toast_element=WebDriverWait(driver,5).until(lambda x:x.find_element_by_xpath(message)) print(toast_element.text)
# -*- conding: utf-8 -*- # @Time :2019/10/10 14:15 # Author :chengjin # @Email :[email protected] # @File :kyb_login.py from find_element.capability import driver, NoSuchElementException def login(): driver.find_element_by_id("com.tal.kaoyan:id/login_email_edittext").clear() driver.find_element_by_id( "com.tal.kaoyan:id/login_email_edittext").send_keys("自学网2018") driver.find_element_by_id( "com.tal.kaoyan:id/login_password_edittext").send_keys("zxw2018") driver.find_element_by_id("com.tal.kaoyan:id/login_login_btn").click() try: driver.find_element_by_id("com.tal.kaoyan:id/mainactivity_button_mysefl") except: login() else: driver.find_element_by_id( "com.tal.kaoyan:id/mainactivity_button_mysefl").click() driver.find_element_by_id( "com.tal.kaoyan:id/activity_usercenter_username").click() login() driver.findui
y1=int(l[1]*0.5) x2=int(l[0]*0.1) driver.swipe(x1,y1,x2,y1,1000) def swipeUp(): l = get_size() x1 = int(l[0] * 0.5) y1 = int(l[1] * 0.95) y2 = int(l[1] * 0.35) driver.swipe(x1, y1, x1, y2, 1000) def swipeDown(): l=get_size() x1 = int(l[0] * 0.5) y1 = int(l[1] * 0.35) y2 = int(l[1] * 0.85) driver.swipe(x1, y1, x1, y2, 1000) def swipeRight(): l=get_size() y1 = int(l[1] * 0.5) x1 = int(l[0] * 0.25) x2 = int(l[0] * 0.95) driver.swipe(x1, y1, x2, y1, 1000) for i in range(2): swipeLeft() sleep(0.5) driver.find_element_by_id('com.tal.kaoyan:id/activity_splash_guidfinish').click()
from find_element.capability import driver driver.find_element_by_id('com.tal.kaoyan:id/login_register_text').click() root_element=driver.find_element_by_id('com.tal.kaoyan:id/activity_register_parentlayout') root_element.find_element_by_class_name('android.widget.ImageView').click()
from find_element.capability import driver driver.find_element_by_id( 'com.tal.kaoyan:id/mainactivity_button_mysefl').click() driver.find_element_by_id( 'com.tal.kaoyan:id/activity_usercenter_username').click() driver.find_element_by_id('com.tal.kaoyan:id/login_email_edittext').clear() driver.find_element_by_id('com.tal.kaoyan:id/login_email_edittext').send_keys( 'sssss') driver.find_element_by_id( 'com.tal.kaoyan:id/login_password_edittext').send_keys('zxw2018') # driver.save_screenshot('login.png') print('1') try: driver.get_screenshot_as_file('./images/login.png') except Exception as e: print(e) driver.find_element_by_id('com.tal.kaoyan:id/login_login_btn').click()
#!/usr/bin/env python3 # -*- coding:utf-8 -*- from find_element.capability import driver from selenium.webdriver.support.ui import WebDriverWait driver.find_element_by_id("com.tal.kaoyan:id/login_email_edittext").clear() driver.find_element_by_id("com.tal.kaoyan:id/login_email_edittext").send_keys( "bryce123") driver.find_element_by_id( "com.tal.kaoyan:id/login_password_edittext").send_keys("74505208") driver.find_element_by_id("com.tal.kaoyan:id/login_login_btn").click() error_message = "用户名或密码错误,你还可以尝试2次" limit_message = "验证失败次数过多,请15分钟后再试" message = "//*[@text='{}']".format(error_message) # message = "//*[@text='{}']".format(limit_message) toast_element = WebDriverWait( driver, 5).until(lambda x: x.find_element_by_xpath(message)) print(toast_element.text) if __name__ == '__main__': print("ok")
# -*- conding: utf-8 -*- # @Time :2019/10/10 14:15 # Author :chengjin # @Email :[email protected] # @File :kyb_login.py from find_element.capability import driver, NoSuchElementException import time driver.find_element_by_id("com.tal.kaoyan:id/activity_splash_top").click() time.sleep(3) driver.find_element_by_id("com.tal.kaoyan:id/home_top_search_layout").click() time.sleep(3) # driver.find_element_by_id(" com.tal.kaoyan:id/customsearchview_contentedittext").click() driver.find_element_by_id( "com.tal.kaoyan:id/customsearchview_contentedittext").send_keys("心理学") time.sleep(3) driver.find_element_by_id( "com.tal.kaoyan:id/customsearchview_searchbtn").click()
#! /usr/bin/env/python # -*- coding:utf-8 -*- from find_element.capability import driver lotteries_btn = driver.find_element_by_id( 'com.multilotto.lottery:id/radio_lotteries') lotteries_btn.click() lotto_pw = driver.find_element_by_xpath('//*[@text="powerball"]') lotto_pw.click()