gpt4 book ai didi

Python Appium 实现页面对象模型

转载 作者:行者123 更新时间:2023-11-30 22:34:29 27 4
gpt4 key购买 nike

我正在尝试使用 appium 实现“By”和“Keys”,就像我在 selenium 上实现的那样。

在 Selenium 上我可以这样做:

定位器

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"]')

功能

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)

appium 有办法做到这一点吗?如果我这样做,就没有模块:

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

最佳答案

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')

关于Python Appium 实现页面对象模型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44830028/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com