Appium_iOS_Safari test scripts (2)

After several debug, test scripts can be run on Safari finally, but some elements still can not identify, also need to continue to debug;

#!/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 () # maximized window 
        self.driver.implicitly_wait ( 10 ) # Implicit wait 

    DEF test_login_demo (Self):
         the try : 
            login_click = " "" 
                            the setTimeout (function () { 
                                // query button click 5 second delay (the setTimeout is asynchronous) 
                                var = document.querySelector Login ( "# Header> Li: Child-Nth (. 4)> div> span: Child-Nth (. 1)"); 
                                login.click (); 
                            }, 5000); 
                            "" " 
            self.driver.execute_script (login_click) # JS query and click
            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("[email protected]")
            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()

 

Guess you like

Origin www.cnblogs.com/jiguanghover/p/12545428.html