2017-06-29 3 views
1

Ich versuche, 'By' und 'Keys' mit Appium zu implementieren, genau wie ich es auf Selen mache.Python Appium Implementierung von Page Object Model

Auf Selen konnte ich dies tun:

Locators

from selenium.webdriver.common.by import By 

class LoginPageLocators(object): 
    HEADING = (By.CSS_SELECTOR, 'h3[class="panel-title"]') 
    USERNAME = (By.NAME, 'username') 
    PASSWORD = (By.NAME, 'password') 
    LOGIN_BTN = (By.CSS_SELECTOR, 'input[value="Login"]') 

Funktionen

from selenium import webdriver 
from selenium.webdriver.common.keys import Keys 
from base import Page 
from locators.locators import * 

class LoginPage(Page): 

    def __init__(self, context): 
     Page.__init__(
      self, 
      context) 

    def goto_login_page(self, url): 
     self.open(url) 

    def enter_username(self, username): 
     uname = self.find_element(*LoginPageLocators.USERNAME) 
     uname.send_keys(username) 

    def enter_password(self, password): 
     pword = self.find_element(*LoginPageLocators.PASSWORD) 
     pword.send_keys(password) 

    def click_login(self): 
     login = self.find_element(*LoginPageLocators.LOGIN_BTN) 
     login.click() 

    def verify_dashboard_page(self, page): 
     self.verify_page(page) 

Gibt es eine Möglichkeit, um diese in appium? es gibt kein Modul, wenn ich dies tun:

from appium.webdriver.common.by import By 
from appium.webdriver.common.keys import Keys 

Antwort

1
from appium.webdriver.common.mobileby import By 
from appium.webdriver.common.mobileby import MobileBy 

class FirstPageLocators(object): 
    LOCATOR_ONE = (MobileBy.ACCESSIBILITY_ID, 'id') 
    LOCATOR_TWO = (MobileBy.XPATH, 'xpath_value') 
Verwandte Themen