Best Python code snippet using selene_python
config.py
Source:config.py
...118 self._set_driver = lambda: driver119 self._source.create()120 else:121 auto_set_driver = (122 lambda: self._set_chrome_or_firefox_from_webdriver_manager()123 )124 self._set_driver = set_driver or auto_set_driver125 self._save_screenshot_on_failure = save_screenshot_on_failure126 self._save_page_source_on_failure = save_page_source_on_failure127 self._poll_during_waits = poll_during_waits128 self._counter = counter or itertools.count(129 start=int(round(time.time() * 1000))130 )131 self._reports_folder = reports_folder or os.path.join(132 os.path.expanduser('~'),133 '.selene',134 'screenshots',135 str(next(self._counter)),136 )137 self._last_screenshot = (138 last_screenshot139 if isinstance(last_screenshot, Source)140 else Source(last_screenshot)141 )142 self._last_page_source = (143 last_page_source144 if isinstance(last_page_source, Source)145 else Source(last_page_source)146 )147 super().__init__(148 driver=driver,149 timeout=timeout,150 base_url=base_url,151 set_value_by_js=set_value_by_js,152 type_by_js=type_by_js,153 wait_for_no_overlap_found_by_js=wait_for_no_overlap_found_by_js,154 window_width=window_width,155 window_height=window_height,156 hook_wait_failure=hook_wait_failure,157 log_outer_html_on_failure=log_outer_html_on_failure,158 )159 def _set_chrome_or_firefox_from_webdriver_manager(self):160 def get_chrome():161 return Chrome(162 service=ChromeService(163 ChromeDriverManager(164 chrome_type=ChromeType.CHROMIUM165 ).install()166 ),167 options=ChromeOptions(),168 )169 def get_firefox():170 return Firefox(171 service=FirefoxService(GeckoDriverManager().install())172 )173 return {'chrome': get_chrome, 'firefox': get_firefox}.get(174 self.browser_name175 )()176 @property177 def driver(self) -> WebDriver:178 return self._source.instance179 def get_or_create_driver(self) -> WebDriver:180 return self._source.get_or_create()181 def quit_driver(self):182 warnings.warn(183 'shared.config.quit_driver is deprecated, '184 'use shared.config.reset_driver instead',185 DeprecationWarning,186 )187 self.reset_driver()188 def reset_driver(self):189 self.set_driver = (190 lambda: self._set_chrome_or_firefox_from_webdriver_manager()191 )192 @driver.setter193 def driver(self, value: WebDriver):194 self.set_driver = (195 lambda: value196 )197 self._source.create()198 @property199 def set_driver(self):200 return self._set_driver201 @set_driver.setter202 def set_driver(self, value: Callable[[], WebDriver]):203 self._source.quit()204 self._set_driver = value...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!