Best Python code snippet using robotframework-anywherelibrary
element.py
Source:element.py
...45 | type | ${element_locator} | ${Text} |46 """47 self._info("Typing text '%s' into text field '%s'" % (text, locator))48 self.wait_for_element_present(locator,10)49 self._input_text_into_text_field(locator, text)50 if Util.captureScreenShot=="True":51 self.capture_page_screenshot()52 53 def is_element_present(self,locator):54 """Return true or false if element presents in current page.55 """56 return (self.element_find(locator,False) != None)57 58 def page_should_contain_element(self,locator):59 """Verifies that current page contains element.60 """61 if self.is_element_present(locator):62 self._info('Current page contains element with locator %s'%locator)63 else:64 self._warn('Current page should not contain element with locator %s'%locator)65 def page_should_not_contain_element(self,locator):66 """Verifies that current page should not contain element.67 """68 if not self.is_element_present(locator):69 self._info('Current page should not contain element with locator %s'%locator)70 else:71 self._warn('Current page contains element with locator %s'%locator)72 73 def get_matching_element_count(self, locator):74 """Returns number of elements matching `locator`75 """76 if self._element_finder.find(locator) is None:77 count=078 else:79 count = len(self._element_finder.find(locator))80 return str(count)81 82 def get_text(self,locator):83 """Returns the text value of element identified by `locator`.84 """85 return self._get_text(locator)86 87 def get_value(self,locator):88 """Returns the value attribute of element identified by `locator`.89 """90 return self._get_value(locator)91 92 def verify_text(self,locator,expectedText):93 """Compare the expectedText given to the actualText which get from the element.94 95 *expectedText* argument specifies the expectedtext you want.96 97 Example:98 | Verify text | ${element_locator} | ${text} |99 100 """101 try:102 actualText=self._get_text(locator)103 assert actualText==expectedText104 self._info('Compare actual text(%s) with expected text(%s) passed'%(actualText,expectedText))105 except AssertionError:106 self._warn('Compare actual text(%s) with expected text(%s) failed'%(actualText,expectedText))107 108 def verify_value(self,locator,expectedValue):109 """Compare the expectedValue given to the actualValue which get from the element110 111 *expectedValue* argument specifies the expectedValue you want.112 113 Example:114 | Verify value | ${element_locator} | ${value} |115 """116 try:117 actualValue=self._get_value(locator)118 assert actualValue==expectedValue119 self._info('Compare actual value(%s) with expected value(%s) passed'%(actualValue,expectedValue))120 except AssertionError:121 self._warn('Compare actual value(%s) with expected value(%s) failed'%(actualValue,expectedValue))122 123 def ie_certificate_error_handler(self):124 Util.driver.get(('javascript:document.getElementById("overridelink").click()')) 125 126 # Private127 def _input_text_into_text_field(self, locator, text):128 element = self.element_find(locator)129 element.send_keys(text)130 131 def _get_text(self,locator):132 element=self.element_find(locator)133 return (element.text).strip()134 135 def _get_value(self,locator):136 element=self.element_find(locator)137 return (element.get_attribute("value")).strip()138 ...
Plugin.py
Source:Plugin.py
...32 if isinstance(password, str) and re.fullmatch(self.crypto.CIPHER_PATTERN, password):33 plaintext = self.crypto.decrypt_text(password)34 else:35 plaintext = password36 self._input_text_into_text_field(locator, plaintext, clear)37 def _input_text_into_text_field(self, locator, text, clear=True):38 element = self.find_element(locator)39 if is_truthy(clear):40 element.clear()41 previous_level = BuiltIn().set_log_level('NONE')42 try:43 element.send_keys(text)44 finally:...
ExtendedSelenium2Library.py
Source:ExtendedSelenium2Library.py
...11 def get_markdown_text_from_file(self, locator):12 with open('markdown.txt') as f:13 content = f.readlines()14 self._info("Typing text '%s' into text field '%s'" % ("from file", locator))...
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!!