• Appium_iOS_Safari测试脚本(2)


    经过多次调试,在Safari上的测试脚本终于可以运行了,不过部分元素还是无法识别,还需要继续调试;

    #!/usr/bin/env/python
    # -*-coding:utf-8-*-
    
    import pytest
    from time import sleep
    from selenium import webdriver
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support.wait import WebDriverWait
    from selenium.webdriver.support import expected_conditions as EC
    
    
    class TestSafari:
    
        def setup(self):
            self.driver = webdriver.Safari()
            self.driver.get("https://www.xxxyyy.org")
            self.driver.maximize_window()  # 最大化窗口
            self.driver.implicitly_wait(10)  # 隐式等待
    
        def test_login_demo(self):
            try:
                login_click = """
                                setTimeout(function() {
                                    // 延迟 5 秒点击查询按钮(setTimeout是异步执行)
                                    var login = document.querySelector("#Header>li:nth-child(4)>div>span:nth-child(1)") ; 
                                    login.click() ;
                                } , 5000) ;
                                """
                self.driver.execute_script(login_click)  # JS查询并点击
                sleep(1)
                # input username
                email_input = WebDriverWait(self.driver, 10).until(
                    EC.visibility_of_element_located((By.XPATH, '//*[@id="Qign"]/table/tbody/div/div/div[1]/form/div[2]/input')))
                # email_input = self.driver.find_element_by_xpath(
                #     '//*/input[@name="email"]')
                email_input.send_keys("aaa@163.com")
                sleep(1)
    
                # input password
                pass_input = self.driver.find_element_by_xpath(
                    '//*[@id="Bign"]/table/tbody/tr/td/div/form/div[3]/input')
                pass_input.send_keys("bbbbbb")
    
                # assert login page
                login_phone_text = self.driver.find_element_by_xpath(
                    '//*[@id="Sign"]/table/tbody/div/div/div[1]/form/div[1]')
                assert 'Login with Phone' in login_phone_text.text
    
                # click login button
                login_btn = WebDriverWait(self.driver, 10).until(
                    EC.visibility_of_element_located(
                        (By.XPATH, '//*[@id="Sign"]/table/tbody/div/div/div[1]/form/div[5]/button')))
                login_btn.click()
                
            except Exception as e:
                print("Login exception>>",e)
    
        def teardown(self):
            sleep(30)
            self.driver.quit()
  • 相关阅读:
    Rio手把手教学:如何打造容器化应用程序的一站式部署体验
    OCR技术浅探: 语言模型和综合评估(4)
    OCR技术浅探: 光学识别(3)
    OCR技术浅探 : 文字定位和文本切割(2)
    OCR技术浅探:特征提取(1)
    .NET加密方式解析--散列加密
    在Windows上搭建Git Server
    感知机
    企业级负载平衡概述
    Logistic Regression 模型
  • 原文地址:https://www.cnblogs.com/jiguanghover/p/12545428.html
Copyright © 2020-2023  润新知