基于Selenium的web自动化框架(3)

发表于:2016-11-23来源:测试改进工场作者:测试改进工场点击数: 标签:框架
页面基类BasePage.py: class BasePage(object): description of class # webdriver instance def __init__ (self, driver): self.driver = driver LoginPage页面继承自BasePage,并进行Login Page的元素

页面基类BasePage.py:

class BasePage(object):  
    """description of class"""  
  
    #webdriver instance  
    def __init__(self, driver):  
        self.driver = driver  

 

LoginPage页面继承自BasePage,并进行Login Page的元素定位及操作实现。代码中定位了username和password,并且添加了设置用户名和密码的操作。

复制代码
from BasePage import BasePage  
from selenium.webdriver.common.by import By  
from selenium.webdriver.common.keys import Keys  
  
class LoginPage(BasePage):  
    """description of class"""  
     #page element identifier  
    usename = (By.ID,'username')  
    password = (By.ID, 'password')  
    dialogTitle = (By.XPATH,"//h3[@class=\"modal-title ng-binding\"]" 



           

原文转自:http://www.cnblogs.com/AlwinXu/p/5836709.html

...