How to use show_element method in SeleniumBase

Best Python code snippet using SeleniumBase

showtoolspage.py

Source:showtoolspage.py Github

copy

Full Screen

...471 ##########################################################################################472 # NOT TO BE CONFUSED WITH THE JAWBONE FUCNTINOS ABOVE, THESE FUCNTIONS SOLELY WORK WITHIN473 # THE USE CASES WHEN A USER MOUSES OVER A SHOW ELEMENT, CAUSING A "BOB CONTAINER" to appear474 # NETFLIX CALLS THIS THE "BOB-CARD" "BOB OVERLAY" "BOB-JAW-HITZONE"475 def mouse_over_show_element(self, show_element):476 """Mouse over a show_element to force the bob-container/show-preview to open."""477 action = ActionChains(self.driver)478 action.move_to_element(show_element).perform()479 # Wait for bob container/show-preview to open480 wait = WebDriverWait(self.driver, 10)481 wait.until(EC.visibility_of_element_located((self.BOB_PLAY_HITZONE)))482 wait = WebDriverWait(self.driver, 10)483 wait.until(EC.visibility_of_element_located((self.BOB_MY_LIST_BUTTON)))484 def show_is_being_previewed(self):485 """Return true if there is a show that is currently being moused over, false if else.486 Equivalent to is_bob_container_open() if it existed."""487 # NOTE- only one show can be previewed at a time so its valid just to search the entire dom488 try:489 self.driver.find_element(*self.BOB_PLAY_BUTTON)490 return True491 except NoSuchElementException:492 return False493 def mouse_over_show_if_not_moused_over(self, show_element):494 """Open the bob-container/show-preview of a show_element if it's not already open."""495 if self.show_is_being_previewed():496 pass497 # print("show is already being mousedover, mouse_over_show_if_not_moused_over not exe")498 else:499 self.mouse_over_show_element(show_element)500 def close_show_preview(self):501 """Close any show preview by mousing over the home button at the top of the page"""502 home_button = self.driver.find_element(*self.HOME_BUTTON)503 bob_play_hitzone = self.driver.find_element(*self.BOB_PLAY_HITZONE)504 action = ActionChains(self.driver)505 action.move_to_element(home_button).perform()506 wait = WebDriverWait(self.driver, 10)507 wait.until(EC.invisibility_of_element_located(bob_play_hitzone))508 def open_jawbone_from_show_preview(self, show_element):509 """Open the jawbone of show_element via the show_preview."""510 # TODO- Add logic to check if jawbone is already open.511 self.mouse_over_show_if_not_moused_over(show_element)512 bob_jawbone_hitzone = self.driver.find_element(*self.BOB_JAWBONE_HITZONE)513 bob_jawbone_hitzone.click()...

Full Screen

Full Screen

webdriver.py

Source:webdriver.py Github

copy

Full Screen

...87 else:88 raise NameError(89 "Please enter the correct targeting elements,'id_/name/class_name/tag/link_text/xpath/css/android_uiautomator/accessibility_id'.")90 return elem91def show_element(elem):92 """93 Show the elements of the operation94 :param elem:95 """96 style_red = 'arguments[0].style.border="2px solid #FF0000"'97 style_blue = 'arguments[0].style.border="2px solid #00FF00"'98 style_null = 'arguments[0].style.border=""'99 try:100 for _ in range(2):101 Fxtest.driver.execute_script(style_red, elem)102 time.sleep(0.1)103 Fxtest.driver.execute_script(style_blue, elem)104 time.sleep(0.1)105 Fxtest.driver.execute_script(style_blue, elem)106 time.sleep(0.3)107 Fxtest.driver.execute_script(style_null, elem)108 except Exception as e:109 log.warn(e)110 pass111class WebDriver(object):112 current_window=None113 class Key:114 def __init__(self, index=0, **kwargs):115 self.elem=get_element(**kwargs)[index]116 show_element(self.elem)117 def input(self, text=""):118 self.elem.send_keys(text)119 def enter(self):120 self.elem.send_keys(Keys.ENTER)121 def select_all(self):122 self.elem.send_keys(Keys.CONTROL, "a")123 def copy(self):124 self.elem.send_keys(Keys.CONTROL, "c")125 def cut(self):126 self.elem.send_keys(Keys.CONTROL, "x") 127 128 def paste(self):129 self.elem.send_keys(Keys.CONTROL, "v") 130 131 def get(self,url):132 """133 self.get(url)134 输入地址后,浏览器打开该地址135 """136 Fxtest.driver.get(url)137 def max_window(self):138 Fxtest.driver.maximize_window()139 def set_window(self,wide,high):140 Fxtest.driver.set_window_size(wide, high)141 def clear(self, index=0, **kwargs):142 elem=get_element(**kwargs)[index]143 show_element(elem)144 elem.clear()145 def input_text(self,text="",clear=False,index=0,enter=False,**kwargs):146 if clear is True:147 self.clear(index,**kwargs)148 elem=get_element(**kwargs)[index]149 show_element(elem)150 log.info(" input '{text}'.".format(text=text))151 elem.send_keys(text)152 if enter is True:153 elem.send_keys(Keys.ENTER)154 155 def click(self, index=0,**kwargs):156 elem=get_element(**kwargs)[index]157 show_element(elem)158 log.info(" click.")159 elem.click()160 161 def slow_click(self,index=0,**kwargs):162 elem = get_element(**kwargs)[index]163 show_element(elem)164 log.info(" click.")165 ActionChains(Fxtest.driver).move_to_element(elem).click(elem).perform()166 167 def right_click(self,index=0,**kwargs):168 elem = get_element(**kwargs)[index]169 show_element(elem)170 ActionChains(Fxtest.driver).context_click(elem).perform() 171 def move_to_element(self, index=0, **kwargs):172 """173 """174 elem = get_element(**kwargs)[index]175 show_element(elem)176 ActionChains(Fxtest.driver).move_to_element(elem).perform() 177 def double_click(self, index=0, **kwargs):178 """179 """180 elem = get_element(**kwargs)[index]181 show_element(elem)182 ActionChains(Fxtest.driver).double_click(elem).perform() 183 def close(self):184 """185 """186 Fxtest.driver.close()187 def quit(self):188 """189 """190 Fxtest.driver.quit()191 def refresh(self):192 """193 """194 Fxtest.driver.refresh()195 def execute_script(self, script, *args):196 """197 """198 return Fxtest.driver.execute_script(script, *args)199 def get_attribute(self, attribute=None, index=0, **kwargs):200 """201 """202 if attribute is None:203 raise ValueError("attribute is not None")204 elem = get_element(**kwargs)[index]205 show_element(elem)206 return elem.get_attribute(attribute)207 def get_text(self, index=0, **kwargs):208 """209 210 """211 elem = get_element(**kwargs)[index]212 show_element(elem)213 return elem.text214 def get_display(self, index=0, **kwargs):215 """216 """217 elem = get_element(**kwargs)[index]218 show_element(elem)219 return elem.is_displayed()220 221 @property222 def get_title(self):223 """224 """225 return Fxtest.driver.title226 def wait(self, time=10):227 """228 """229 Fxtest.driver.implicitly_wait(time)230 231 def switch_to_frame(self, index=0, **kwargs):232 """233 """234 elem = get_element(**kwargs)[index]235 show_element(elem)236 Fxtest.driver.switch_to.frame(elem)237 def switch_to_frame_out(self):238 """239 """240 Fxtest.driver.switch_to.default_content()241 242 @staticmethod243 def sleep(sec):244 """245 Usage:246 self.sleep(seconds)247 """248 time.sleep(sec)249 def wait_elements(self, interval=0.5,element=None ):...

Full Screen

Full Screen

show_page.py

Source:show_page.py Github

copy

Full Screen

...9 def __init__(self,driver,logger):10 self.logger = logger11 super(ShowPage,self).__init__(driver,self.logger)12 self.get_ele = GetElement(driver,self.logger)13 def get_pic_or_doc_show_element(self):14 return self.get_ele.get_element("pic_or_doc_show","show_element")15 def get_video_show_element(self):16 return self.get_ele.get_element("video_show","show_element")17 def get_audio_show_element(self):18 return self.get_ele.get_element("audio_show","show_element")19 def get_scorm_show_element(self):20 return self.get_ele.get_element("scorm_show","show_element")21 def get_html_show_element(self):22 return self.get_ele.get_element("html_show","show_element")23 def get_fresh_btn_element(self):24 return self.get_ele.get_element("fresh_btn","show_element")25 def get_download_element(self):26 return self.get_ele.get_element("download_btn","show_element")27 def download(self):28 ele = self.get_download_element()29 self.click_element(ele)30 def delete_download_file(self,*args,**kwargs):31 #如果本地已有文件,则删除32 OperaFile(kwargs["filename"],kwargs["file_type"],self.logger).delete_file()33 def check_download_status(self,*args,**kwargs):34 #这里之所以用上传文件路径,是因为上传路径是可以控制的,而下载路径可能随环境改变而变动(此处下载路径没地方设置)35 #下载路径拼接上传文件名称,则构成下载之后的文件名称36 op_file = OperaFile(kwargs["filename"],kwargs["file_type"],self.logger)37 for i in range(10):38 if op_file.check_file_status():39 return "true"40 else:41 time.sleep(10)42 return "false"43 def check_pic_encode_status(self):44 # 在列表页点击图片名称45 self.get_ele.wait_element_disappear("loading_status","kng_element")46 jpg_file_element = self.get_jpg_file_element()47 self.click_element(jpg_file_element)48 self.switch_window()49 ele = self.get_pic_or_doc_show_element()50 if ele:51 self.logger.info("图片转换成功")52 return True53 else:54 self.logger.error("图片转换失败")55 return False56 def check_doc_encode_status(self):57 self.get_ele.wait_element_disappear("loading_status", "kng_element")58 self.click_element(self.get_doc_file_element())59 self.switch_window()60 for i in range(10):61 if self.get_ele.wait_element_disappear("doc_encode_status", "show_element"):62 break63 else:64 #整个页面刷新,局部刷新按钮点击之后有bug65 self.refresh()66 ele = self.get_pic_or_doc_show_element()67 if ele:68 self.logger.info("文档转换成功")69 return True70 else:71 self.logger.error("文档转换失败")72 return False73 def check_video_encode_status(self):74 self.get_ele.wait_element_disappear("loading_status", "kng_element")75 self.click_element(self.get_video_file_element())76 self.switch_window()77 for i in range(20):78 if self.get_ele.wait_element_disappear("video_encode_status", "show_element"):79 break80 else:81 # 整个页面刷新,局部刷新按钮点击之后有bug82 self.refresh()83 ele = self.get_video_show_element()84 if ele:85 self.logger.info("视频转换成功")86 return True87 else:88 self.logger.error("视频转换失败")89 return False90 def check_audio_encode_status(self):91 self.get_ele.wait_element_disappear("loading_status", "kng_element")92 self.click_element(self.get_audio_file_element())93 self.switch_window()94 for i in range(20):95 if self.get_ele.wait_element_disappear("audio_encode_status", "show_element"):96 break97 else:98 # 整个页面刷新,局部刷新按钮点击之后有bug99 self.refresh()100 ele = self.get_audio_show_element()101 if ele:102 self.logger.info("音频转换成功")103 return True104 else:105 self.logger.error("音频转换失败")106 return False107 def check_scorm_encode_status(self):108 self.get_ele.wait_element_disappear("loading_status", "kng_element")109 self.click_element(self.get_scorm_file_element())110 self.switch_window()111 for i in range(20):112 if self.get_ele.wait_element_disappear("scorm_encode_status", "show_element"):113 break114 else:115 # 整个页面刷新,局部刷新按钮点击之后有bug116 self.refresh()117 ele = self.get_scorm_show_element()118 self.close()119 self.switch_window(0)120 if ele:121 self.logger.info("scorm转换成功")122 return "true"123 else:124 self.logger.error("scorm转换失败")125 return "false"126 def check_html_encode_status(self):127 self.get_ele.wait_element_disappear("loading_status", "kng_element")128 self.click_element(self.get_scorm_file_element())129 self.switch_window()130 for i in range(20):131 if self.get_ele.wait_element_disappear("html_encode_status", "show_element"):132 break133 else:134 # 整个页面刷新,局部刷新按钮点击之后有bug135 self.refresh()136 ele = self.get_html_show_element()137 self.close()138 self.switch_window(0)139 if ele:140 self.logger.info("html转换成功")141 return "true"142 else:143 self.logger.error("html转换失败")144 return "false"145 def check_encode_status(self,file_type):146 if file_type == "pic":147 #在播放页查看图片是否正常148 return self.check_pic_encode_status()149 elif file_type == "doc":150 return self.check_doc_encode_status()...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run SeleniumBase automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful