''''
@project: ***
@description: webdriver api二次封裝類
@time:2019/11/11 18:51
@author:ming
'''from selenium import webdriver
from selenium.webdriver.support.select import select
# 建立類
class autodriver():
# 構造初始化方法
def __init__(self):
# 瀏覽器物件例項化
self.driver = webdriver.firefox()
# 繫結url
self.base_url =''
#開啟url
def open_url(self,url):
self.driver.get(self.base_url+url)
#全屏def max_window(self):
self.driver.maximize_window()
#關閉瀏覽器 close quit
def close_page(self):
self.driver.close()
#八大定位
def find_e_element(self,by,selector):
if by=='id' or by =='i':
return self.driver.find_element_by_id(selector)
elif by=='name' or by=='n':
return self.driver.find_element_by_name(selector)
elif by=='class_name' or by=='c':
return self.driver.find_element_by_class_name(selector)
elif by=='tag_name' or by=='t':
return self.driver.find_element_by_tag_name(selector)
elif by=='link_text' or by=='l':
return self.driver.find_element_by_link_text(selector)
elif by=='partial_link_text' or by=='plt':
return self.driver.find_element_by_partial_link_text(selector)
elif by=='xpath' or by=='x':
return self.driver.find_element_by_xpath(selector)
elif by=='css_selector' or by=='cs':
return self.driver.find_element_by_css_selector(selector)
#警告框
def switch_alert(self,value):
if value=='accept' or value=='a':
return self.driver.switch_to.alert.accept()
elif value=='dismiss' or value=='d':
return self.driver.switch_to.alert.dismiss()
#下拉 by:屬性 selector:屬性值 val:下拉屬性 value:下拉值
def select_value(self,by,selector,val,value):
if val=='value' or val=='v':
return select(self.find_e_element(by,selector)).select_by_value(value)
elif val=='index' or val=='i':
return select(self.find_e_element(by,selector)).select_by_index(value)
elif val=='visible_text' or val=='vt':
return select(self.find_e_element(by,selector)).select_by_visible_text(value)
Android 介面卡 Adapter 二次封裝
介面卡父類 版權 建立者 shuquan 模組 描述 介面卡父類 public abstract class baseadapterextends recyclerview.adapter override public baseviewholder oncreateviewholder viewg...
tipask二次開發總結 tipask二次開發總結
條件模板 statement1 statement2 statement3 不帶下標變數的陣列迴圈 statement php的迴圈輸入 foreach array as value statement foreach array as key value 可以引用介面替換變數,其中必須為大寫字母,...
多元二次方程 python Python 二次方程
python 二次方程 以下例項為通過使用者輸入數字,並計算二次方程 coding utf 8 filename test.py author by www.xiaoushuo.com 二次方程式 ax 2 bx c 0 a b c 使用者提供 匯入 cmath 複雜數 算 模組 import cm...