def focus(self, target, value): locator = create_locator(target) element = locator.get_element(self.webdriver) if element.get_attribute('id'): self.webdriver.execute_script( 'document.getElementById("%s").focus();' % element.get_attribute('id'))
def select(self,target,value): # find select(target) and set it's value sel_elem = create_locator(target).get_element(self.webdriver) if value.startswith('id='): raise NotImplemented elif value.startswith('index='): index=int(value[6:]) child=sel_elem.find_elements_by_tag_name("option")[index] elif value.startswith('value='): raise NotImplemented elif value.startswith('label='): raise NotImplemented else: # assume label= raise NotImplemented child.click()
def click(self, target, value): create_locator(target).get_element(self.webdriver).click()
def check(self, target, value): element = create_locator(target).get_element(self.webdriver) if element.get_attribute('type') == 'checkbox' and not element.get_attribute('checked'): element.click()
def assertText(self, target, value): locator = create_locator(target) pattern = create_pattern(value) return pattern.compare(locator.get_element(self.webdriver).text)
def assertElementPresent(self, target, value): try: create_locator(target).get_element(self.webdriver) return True except NoSuchElementException: return False
def typeKeys(self, target, value): create_locator(target).get_element(self.webdriver).send_keys(value)
def focus(self, target, value): locator = create_locator(target) element = locator.get_element(self.webdriver) if element.get_attribute('id'): self.webdriver.execute_script('document.getElementById("%s").focus();' % element.get_attribute('id'))
def check(self, target, value): element = create_locator(target).get_element(self.webdriver) if element.get_attribute("type") == "checkbox" and not element.get_attribute("checked"): element.click()
def check(self, target, value): element = create_locator(target).get_element(self.webdriver) if element.get_attribute( 'type') == 'checkbox' and not element.get_attribute('checked'): element.click()