Best Python code snippet using pytractor_python
test_mixins.py
Source:test_mixins.py  
...350        with patch.object(351            self.instance, 'find_elements_by_exact_binding',352            return_value=[mock_element]353        ) as mock_find_elements_by_exact_binding:354            result = self.instance.find_element_by_exact_binding(355                mock_descriptor, mock_using356            )357        mock_find_elements_by_exact_binding.assert_called_once_with(358            mock_descriptor, using=mock_using359        )360        self.assertIs(result, mock_element)361    def test_find_element_by_exact_binding_raises_error_if_nothing_found(self):362        mock_descriptor = MagicMock()363        mock_using = MagicMock()364        with patch.object(365            self.instance, 'find_elements_by_exact_binding', return_value=[]366        ) as mock_find_elements_by_exact_binding:367            with self.assertRaises(NoSuchElementException):368                self.instance.find_element_by_exact_binding(369                    mock_descriptor, mock_using370                )371        mock_find_elements_by_exact_binding.assert_called_once_with(372            mock_descriptor, using=mock_using373        )374    def test_find_elements_by_exact_binding_calls_protractor_script(self):375        mock_descriptor = MagicMock()376        mock_using = MagicMock()377        with patch.multiple(378            self.instance, wait_for_angular=DEFAULT,379            _execute_client_script=DEFAULT380        ) as mock_methods:381            result = self.instance.find_elements_by_exact_binding(382                mock_descriptor, mock_using...mixins.py
Source:mixins.py  
...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):...test_locators.py
Source:test_locators.py  
...51        element = self.driver.find_element_by_binding('nickname|uppercase')52        self.assertIsInstance(element, WebElement)53        self.assertEqual(element.text, '(ANNIE)')54    def test_find_element_by_exact_binding_finds_correct_element(self):55        element = self.driver.find_element_by_exact_binding('greeting')56        self.assertIsInstance(element, WebElement)57        self.assertEqual(element.text, 'Hiya')58    def test_find_element_by_exact_binding_needs_complete_binding_name(self):59        with self.assertRaises(NoSuchElementException):60            self.driver.find_element_by_exact_binding('greet')61class ByModelLocatorTest(LocatorTestCase):62    def setUp(self):63        self.driver.get('index.html#/form')64    def test_find_element_by_model_finds_element_by_text_input_model(self):65        username = self.driver.find_element_by_model('username')66        name = self.driver.find_element_by_binding('username')67        username.clear()68        self.assertEqual(name.text, '')69        username.send_keys('Jane Doe')70        self.assertEqual(name.text, 'Jane Doe')71        username.clear()72        self.assertEqual(name.text, '')73    def test_find_element_by_model_finds_element_by_checkbox_input_model(self):74        shower = self.driver.find_element_by_id('shower')...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!!
