How to use _parse_locator method in robotframework-appiumlibrary

Best Python code snippet using robotframework-appiumlibrary_python

selenium_plus.py

Source:selenium_plus.py Github

copy

Full Screen

...74 try:75 yield76 finally:77 self.driver.implicitly_wait(SeleniumPlus.IMPLICITLY_WAIT)78 def _parse_locator(self, locator):79 _page, _locator = locator.split(':')80 method = self.locators[_page][_locator]['by'].upper()81 value = self.locators[_page][_locator]['value']82 return method, value83 def _wait_until_element_located(self, locator):84 method, value = self._parse_locator(locator)85 with self.change_implicit_wait():86 return self.wait.until(87 EC.visibility_of_element_located((getattr(By, method), value)),88 message=f"Element with locator {locator} is not on the page or not visible."89 )90 def _wait_until_element_clickable(self, locator):91 method, value = self._parse_locator(locator)92 with self.change_implicit_wait():93 return self.wait.until(94 EC.element_to_be_clickable((getattr(By, method), value)),95 message=f"Element with locator {locator!r} is not clickable."96 )97 def quit_driver(self):98 self.driver.quit()99 def find_element(self, locator):100 method, value = self._parse_locator(locator)101 return self.driver.find_element(by=getattr(By, method), value=value)102 def find_elements(self, locator):103 method, value = self._parse_locator(locator)104 return self.driver.find_elements(by=getattr(By, method), value=value)105 def get_text(self, locator):106 self._wait_until_element_located(locator)107 return self.find_element(locator).text108 def set_text(self, locator, text):109 self._wait_until_element_located(locator)110 self.find_element(locator).clear()111 self.find_element(locator).send_keys(text)112 def click(self, locator):113 self._wait_until_element_clickable(locator)114 self.find_element(locator).click()115 def get_attribute(self, locator, attribute):116 self._wait_until_element_located(locator)117 return self.find_element(locator).get_attribute(attribute)...

Full Screen

Full Screen

test_pytest_pyppeteer.py

Source:test_pytest_pyppeteer.py Github

copy

Full Screen

...16 ("//*[@class and contains(concat(' ', normalize-space(@class), ' '), ' bar ')]", "xpath"),17 ],18)19def test_locator_valid_content(css_or_xpath, expected_type):20 _type, css_or_xpath = _parse_locator(css_or_xpath)21 assert _type == expected_type, "Locator {!r} should be parsed to type {!r}.".format(css_or_xpath, expected_type)22@pytest.mark.parametrize("css_or_xpath", ["##foo", "//foo??", "...."])23def test_locator_invalid_content(css_or_xpath):24 with pytest.raises(ValueError, match=css_or_xpath):25 _parse_locator(css_or_xpath)26@pytest.mark.parametrize("css_or_xpath", [123, 123.0, tuple(), list()])27def test_locator_unsupported_content(css_or_xpath):28 with pytest.raises(TypeError, match="not a string"):29 _parse_locator(css_or_xpath)30def test_platform(platform):31 assert platform is not None32def test_platform_unknown(pytester: Pytester):33 pytester.makeconftest(34 """35 import pytest36 @pytest.fixture(scope="session")37 def platform():38 return "unknown"39 """40 )41 testcase_path = pytester.makepyfile(42 """43 def test_default_executable_path(default_executable_path):...

Full Screen

Full Screen

test_locators.py

Source:test_locators.py Github

copy

Full Screen

...4 @classmethod5 def setUpClass(cls):6 cls.lib = WhiteLibrary()7 def test_no_delimiter(self):8 prefix, value = self.lib._parse_locator("id")9 self.assertEqual(prefix, "id")10 self.assertEqual(value, "id")11 def test_delimiter_colon(self):12 prefix, value = self.lib._parse_locator("index:15")13 self.assertEqual(prefix, "index")14 self.assertEqual(value, "15")15 def test_delimiter_equals(self):16 prefix, value = self.lib._parse_locator("class_name:ComboBox")17 self.assertEqual(prefix, "class_name")18 self.assertEqual(value, "ComboBox")19 def test_delimiter_colon_first(self):20 prefix, value = self.lib._parse_locator("text:=")21 self.assertEqual(prefix, "text")22 self.assertEqual(value, "=")23 def test_delimiter_equals_first(self):24 prefix, value = self.lib._parse_locator("text=Value:")25 self.assertEqual(prefix, "text")26 self.assertEqual(value, "Value:")27 def test_locator_value_contains_delimiter_symbol(self):28 prefix, value = self.lib._parse_locator("text:Value:")29 self.assertEqual(prefix, "text")...

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 robotframework-appiumlibrary 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