代码如下:
1 # basepage.py 2 3 from selenium import webdriver 4 5 6 class BasePage(): 7 """ 8 基类 用作初始化 封装常用操作 9 """ 10 11 def __init__(self): 12 """ 13 初始化driver 14 """ 15 self.driver = webdriver.Firefox() 16 self.calurl = r'http://cal.apple886.com/' 17 self.open_page() 18 19 .... 20 21 def locator(self,by,element): 22 """ 23 元素定位 24 """ 25 self.find_element(by,element)basepage.py
另一个页面代码如下:
1 from basepage.common.basepage import BasePage 2 from selenium.webdriver.common.by import By 3 4 5 # 对象库层 6 class CalElement(BasePage): 7 """ 8 封装各种元素对象:清屏、加、减、乘、除、等于 9 """ 10 def clear_ele(self): 11 """计算器清屏""" 12 self.locator(By.ID,'simpleClearAllBtn') 13 ...... 14 15 if __name__ == "__main__": 16 cal = CalElement() 17 print(cal.clear_ele())cal_page.py
结果报错如下图:
原因:
解决:
标签:__,no,self,object,element,报错,cal,basepage From: https://www.cnblogs.com/T-Better/p/17464336.html