def js_click(self, element): # DriverUtil.get_driver().find_element(element).click() # try: print("{}JS点击按钮成功".format(element)) Driver.get_driver().execute_script("arguments[0].click();", element) # webdriver.ActionChains(DriverUtil.get_driver()).click(element).perform() except Exception as e: print(e, "{}JS点击按钮失败".format(element))
def date_input(self, style, ele, index): """ :param style: CSS元素类型 :param ele: CSS元素 :param index: 下标 :return: """ self.js = 'document.getElementsBy{}("{}")[{}].removeAttribute("readonly")'.format( style, ele, index) Driver.get_driver().execute_script(self.js)
def out_text_iframe(self): # 切出 Driver.get_driver().switch_to.default_content()
def enter_text_iframe(self, iframeid): # 切入 Driver.get_driver().switch_to.frame(iframeid)
def js(self, ele): Driver.get_driver().execute_script(ele)
def scroll(self, ele): Driver.get_driver().execute_script("arguments[0].scrollIntoView();", ele)