Best Python code snippet using robotframework-appiumlibrary_python
ExtendedSeleniumLibrary.py
Source:ExtendedSeleniumLibrary.py
...71 def open_browser(self, url, browser='Chrome', alias=None, remote_url=False,72 desired_capabilities=None, ff_profile_dir=None):73 74 super(ExtendedSeleniumLibrary, self).open_browser(url, browser, alias, remote_url, desired_capabilities, ff_profile_dir)75 self.browsers_number.append(len(self._cache.get_open_browsers()))76 self.events_name.append("Open Browser")77 if self.max_browser_opened < len(self._cache.get_open_browsers()):78 self.max_browser_opened = len(self._cache.get_open_browsers())79 def open_googlechrome(self, alias, remote_url):80 capabilities = {81 "browserName": "chrome",82 "chromeOptions": {83 "args": ["--start-maximized"],84 },85 "loggingPrefs": {86 "browser": "ALL",87 "performance": "ALL"88 },89 "perfLoggingPrefs": {90 "enableNetwork": True91 }92 }93 self.open_browser("about:blank", "googlechrome", alias, remote_url, capabilities)94 def open_chromium(self, alias, remote_url):95 capabilities = {96 "browserName": "chrome",97 "chromeOptions": {98 "args": ["--no-sandbox", "--start-maximized"],99 "binary": "usr/bin/chrome-linux/chrome"100 },101 "loggingPrefs": {102 "browser": "ALL",103 "performance": "ALL"104 },105 "perfLoggingPrefs": {106 "enableNetwork": True107 }108 }109 self.open_browser("about:blank", "googlechrome", alias, remote_url, capabilities)110 def close_browser(self):111 self.collect_network_requests_logs()112 super(ExtendedSeleniumLibrary, self).close_browser()113 self.browsers_number.append(len(self._cache.get_open_browsers()))114 self.events_name.append("Close Browser")115 def close_all_browsers(self):116 self.collect_network_requests_logs()117 super(ExtendedSeleniumLibrary, self).close_all_browsers()118 self.browsers_number.append(len(self._cache.get_open_browsers()))119 self.events_name.append("Close All Browsers")120 def collect_network_requests_logs(self):121 if os.environ.get("GENERATE_NETWORK_REQUESTS_DATA") == 'true':122 network_logs = get_type_logs_from_local_storage("NETWORK_REQUEST")123 if network_logs:...
test_browsercache.py
Source:test_browsercache.py
...19 self.assertEqual(len(cache.browsers), 3)20 self.assertEqual(cache.browsers[0], browser1)21 self.assertEqual(cache.browsers[1], browser2)22 self.assertEqual(cache.browsers[2], browser3)23 def test_get_open_browsers(self):24 cache = BrowserCache()25 browser1 = mock()26 browser2 = mock()27 browser3 = mock()28 cache.register(browser1)29 cache.register(browser2)30 cache.register(browser3)31 browsers = cache.get_open_browsers()32 self.assertEqual(len(browsers), 3)33 self.assertEqual(browsers[0], browser1)34 self.assertEqual(browsers[1], browser2)35 self.assertEqual(browsers[2], browser3)36 cache.close()37 browsers = cache.get_open_browsers()38 self.assertEqual(len(browsers), 2)39 self.assertEqual(browsers[0], browser1)40 self.assertEqual(browsers[1], browser2)41 def test_close(self):42 cache = BrowserCache()43 browser = mock()44 cache.register(browser)45 verify(browser, times=0).quit() # sanity check46 cache.close()47 verify(browser, times=1).quit()48 def test_close_only_called_once(self):49 cache = BrowserCache()50 browser1 = mock()51 browser2 = mock()...
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!!