How to use _test_for_angular method in pytractor

Best Python code snippet using pytractor_python

test_mixins.py

Source:test_mixins.py Github

copy

Full Screen

...152 self.instance, '_execute_client_script'153 ) as mock_execute_client_script:154 self.instance.wait_for_angular()155 self.assertEqual(mock_execute_client_script.call_count, 0)156 def test__test_for_angular(self):157 self.instance._test_timeout = 5000158 self.verify_function_executes_script_with(159 self.instance._test_for_angular,160 'testForAngular', self.instance._test_timeout / 1000161 )162 def test__location_equals(self):163 with patch.object(164 self.instance, 'execute_script', create=True165 ) as mock_execute_script:166 mock_location = MagicMock()167 mock_execute_script.return_value = MagicMock(__eq__=MagicMock())168 result = self.instance._location_equals(mock_location)169 mock_execute_script.assert_called_once_with(170 'return window.location.href'...

Full Screen

Full Screen

TractorScripts.py

Source:TractorScripts.py Github

copy

Full Screen

...220 return self._run_script(self.repeaterMatch)221 @angular_wait_required222 def find_element_by_css_containing_text(self, css_containing_text):223 return self._run_script(self.findByCssContainingText, css_containing_text)224 def _test_for_angular(self, timeout=10):225 return self._run_script(self.testForAngular, floor(timeout / 1000))[0]226 def reload(self):227 url = self.execute_script('return window.location.href')228 self.get(url)229 @angular_wait_required230 def set_location(self, url):231 return self._run_script(self.setLocation, 'body', url)232 def _location_equals(self, location):233 result = self.execute_script('return window.location.href')234 return result == location235 # @property236 # @angular_wait_required237 # def current_url(self):238 # return self.current_url239 @property240 @angular_wait_required241 def current_location(self):242 return self.execute_script('return window.location.href')243 @property244 @angular_wait_required245 def page_source(self):246 return self.page_source247 # TODO: fix issue catching exception248 def is_angular_page(self, timeout=10):249 # test_result = self._test_for_angular()250 # print(test_result)251 # angular_on_page = test_result[0]252 # if not angular_on_page:253 # message = test_result[1]254 # raise AngularNotFoundException(255 # 'Angular could not be found on page: {}:'256 # ' {}'.format(self.current_url, message)257 # )258 try:259 self._test_for_angular(timeout)260 except JavascriptException:261 return False262 return True263 def wait_and_click(self, element, timeout=10):264 wait = WebDriverWait(self, timeout)265 element = wait.until(EC.element_to_be_clickable(element))266 element.click()267 return element268 def exit(self, safe_exit=False):269 """270 Safely exit instance of webdriver.271 :param safe_exit: Disable any possible alert or confirmation popup windows.272 :type safe_exit: bool273 """...

Full Screen

Full Screen

mixins.py

Source:mixins.py Github

copy

Full Screen

...88 if driver_command in COMMANDS_NEEDING_WAIT:89 self.wait_for_angular()90 return super(WebDriverMixin, self).execute(driver_command,91 params=params)92 def _test_for_angular(self):93 return self._execute_client_script('testForAngular',94 floor(self._test_timeout / 1000))95 def _location_equals(self, location):96 result = self.execute_script('return window.location.href')97 return result == location98 @property99 @angular_wait_required100 def current_url(self):101 return super(WebDriverMixin, self).current_url102 @property103 @angular_wait_required104 def page_source(self):105 return super(WebDriverMixin, self).page_source106 @property107 @angular_wait_required108 def title(self):109 return super(WebDriverMixin, self).title110 @property111 @angular_wait_required112 def location_abs_url(self):113 return self._execute_client_script('getLocationAbsUrl',114 self._root_element, async=False)115 @angular_wait_required116 def find_elements_by_repeater(self, descriptor, using=None):117 return self._execute_client_script('findAllRepeaterRows',118 descriptor, False, using,119 async=False)120 @angular_wait_required121 def find_element(self, *args, **kwargs):122 return super(WebDriverMixin, self).find_element(*args, **kwargs)123 @angular_wait_required124 def find_elements(self, *args, **kwargs):125 return super(WebDriverMixin, self).find_elements(*args, **kwargs)126 @angular_wait_required127 def find_elements_by_binding(self, descriptor, using=None):128 elements = self._execute_client_script('findBindings', descriptor,129 False, using, async=False)130 return elements131 def find_element_by_binding(self, descriptor, using=None):132 elements = self.find_elements_by_binding(descriptor, using=using)133 if len(elements) == 0:134 raise NoSuchElementException(135 "No element found for binding descriptor"136 " '{}'".format(descriptor)137 )138 else:139 return elements[0]140 def find_element_by_exact_binding(self, descriptor, using=None):141 elements = self.find_elements_by_exact_binding(descriptor, using=using)142 if len(elements) == 0:143 raise NoSuchElementException(144 "No element found for binding descriptor"145 " '{}'".format(descriptor)146 )147 else:148 return elements[0]149 @angular_wait_required150 def find_elements_by_exact_binding(self, descriptor, using=None):151 elements = self._execute_client_script('findBindings', descriptor,152 True, using, async=False)153 return elements154 def find_element_by_model(self, descriptor, using=None):155 elements = self.find_elements_by_model(descriptor, using=using)156 if len(elements) == 0:157 raise NoSuchElementException(158 "No element found for model descriptor"159 " {}".format(descriptor)160 )161 else:162 return elements[0]163 @angular_wait_required164 def find_elements_by_model(self, descriptor, using=None):165 elements = self._execute_client_script('findByModel', descriptor,166 using, async=False)167 # Workaround for issue #10: findByModel.js returns None instead of empty168 # list if no element has been found.169 if elements is None:170 elements = []171 return elements172 def get(self, url):173 super(WebDriverMixin, self).get('about:blank')174 full_url = urljoin(str(self._base_url), str(url))175 self.execute_script(176 """177 window.name = "{}" + window.name;178 window.location.replace("{}");179 """.format(DEFER_LABEL, full_url)180 )181 wait = WebDriverWait(self, self._test_timeout)182 wait.until_not(self._location_equals, 'about:blank')183 if not self.ignore_synchronization:184 test_result = self._test_for_angular()185 angular_on_page = test_result[0]186 if not angular_on_page:187 message = test_result[1]188 raise AngularNotFoundException(189 'Angular could not be found on page: {}:'190 ' {}'.format(full_url, message)191 )192 # TODO: inject scripts here193 # return self.execute_script(194 # 'angular.resumeBootstrap(arguments[0]);'195 # )196 self.execute_script('angular.resumeBootstrap();')197 def refresh(self):198 url = self.execute_script('return window.location.href')...

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 pytractor 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