zoukankan      html  css  js  c++  java
  • 自动登录苹果id 源代码

    from selenium import webdriver
    import unittest
    import time
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.support import expected_conditions as EC
    from selenium.common.exceptions import TimeoutException, NoSuchElementException
    # firfoxdriver 为 你的firefox安装路径
    import re
    psd1 = []
    k = open(r'C:UsersAdministratorPycharmProjectsuntitled1zidonghuazil', encoding='utf-8')
    for i in k:
        i=i.strip('
    ')
        psd1.append(i)
    mb={psd1[14]:psd1[17],psd1[20]:psd1[23],psd1[26]:psd1[29]}
    print(psd1)
    class GloryRoad(unittest.TestCase):
            def setUp(self):
                self.driver=webdriver.Firefox(executable_path='C:geckodriver')
            def testSoGou(self):
                kk = psd1[2]
                pwd=psd1[5]
                driver=self.driver
                driver.get('https://appleid.apple.com/#!&page=signin')
                try:
                    driver.implicitly_wait(3)#智能等待3秒
                    driver.switch_to.frame('aid-auth-widget-iFrame')
                    driver.find_element_by_id("appleId").send_keys(kk)
                    driver.find_element_by_id("pwd").send_keys(pwd)
                    driver.find_element_by_id('sign-in').click()
                    print('成功')
                except  :
                    print('没有成功')
                time.sleep(3)
                kk1=driver.find_element_by_id('alertInfo').text
                if '回答您的安全提示问题以继续。' in kk1 :
                    print('进入验证阶段')
                else:
                    print('失败')
                    exit()
                k2 = driver.find_elements_by_class_name('form-cell')
                try:
                    driver.implicitly_wait(3)
                    driver.find_element_by_xpath('html/body/div[2]/div/div/div[1]/div[2]/step-challenge-security-questions/idms-step/div/div/div/div/div/div[1]/div/div/idms-textbox/idms-error-wrapper/div/input').send_keys(mb.get(k2[0].text))
                    driver.find_element_by_xpath('html/body/div[2]/div/div/div[1]/div[2]/step-challenge-security-questions/idms-step/div/div/div/div/div/div[2]/div/div/idms-textbox/idms-error-wrapper/div/input').send_keys(mb.get(k2[1].text))
                    driver.find_element_by_xpath('html/body/div[2]/div/div/div[1]/div[3]/div/button[2]').click()
                except:
                    print('没有成功,获取不到数据')
            def tearDown(self):
                pass
                # self.driver.quie
    if __name__=='__main__':
        unittest.main()
    

      



  • 相关阅读:
    Hyperion Planning 表单数据验证功能实现
    类型别名
    内联函数和constexpr函数
    强制类型转换
    当函数返回值是引用
    左值和右值
    const形参和实参
    const限定符
    auto与decltype
    局部对象
  • 原文地址:https://www.cnblogs.com/zj0724/p/8548962.html
Copyright © 2011-2022 走看看