Python selenium.common.exceptions.InvalidElementStateException() Examples
The following are 5
code examples of selenium.common.exceptions.InvalidElementStateException().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
selenium.common.exceptions
, or try the search function
.
Example #1
Source File: grading.py From ANALYSE with GNU Affero General Public License v3.0 | 6 votes |
def cannot_edit_fail(_step): range_css = 'span.letter-grade' ranges = world.css_find(range_css) assert_equal(len(ranges), 2) assert_not_equal(ranges.last.value, 'Failure') # try to change the grade range -- this should throw an exception try: ranges.last.value = 'Failure' except (InvalidElementStateException): pass # We should get this exception on failing to edit the element # check to be sure that nothing has changed ranges = world.css_find(range_css) assert_equal(len(ranges), 2) assert_not_equal(ranges.last.value, 'Failure')
Example #2
Source File: RobotAppEyes.py From Robot-AppEyes with Apache License 2.0 | 5 votes |
def check_eyes_region_by_element(self, selector, value, name, includeEyesLog=False, httpDebugLog=False): """ Takes a snapshot of the region of the given selector and element value from the browser using the web driver and matches it with the expected output. With a choice from four selectors, listed below, to check by. Arguments: | Selector (string) | This will decide what element will be located. The supported selectors include: XPATH, ID, CLASS NAME, CSS SELECTOR | | Value (string) | The specific value of the selector. e.g. an xpath value //*[@id="navbar"]/div/div | | Name (string) | Name that will be given to region in Eyes. | | Include Eyes Log (default=False) | The Eyes logs will not be included by default. To activate, pass 'True' in the variable. | | HTTP Debug Log (default=False) | The HTTP Debug logs will not be included by default. To activate, pass 'True' in the variable. | Example: | *Keywords* | *Parameters* | | Open Browser | http://www.navinet.net/ | gc | | | | | | Open Eyes Session | http://www.navinet.net/ | RobotAppEyes_Test | NaviNet_RobotAppEyes_Test | YourApplitoolsKey | 1024 | 768 | | Check Eyes Region By Element | CLASS NAME | container | NaviNetClassElement | | | | | Close Eyes Session | False | | | | | | """ if includeEyesLog is True: logger.set_logger(StdoutLogger()) logger.open_() if httpDebugLog is True: httplib.HTTPConnection.debuglevel = 1 searchElement = None if selector.upper() == 'XPATH': searchElement = driver.find_element_by_xpath(value) elif selector.upper() == 'ID': searchElement = driver.find_element_by_id(value) elif selector.upper() == 'CLASS NAME': searchElement = driver.find_element_by_class_name(value) elif selector.upper() == 'CSS SELECTOR': searchElement = driver.find_element_by_css_selector(value) else: raise InvalidElementStateException('Please select a valid selector: XPATH, ID, CLASS NAME, CSS SELECTOR') eyes.check_region_by_element(searchElement, name)
Example #3
Source File: user_editable.py From nerodia with MIT License | 5 votes |
def value(self): """ Returns value of the element :rtype: str """ try: return self.attribute_value('value') or '' except InvalidElementStateException: return ''
Example #4
Source File: comment_util.py From FacebookPy with GNU General Public License v3.0 | 4 votes |
def comment_image(browser, username, comments, blacklist, logger, logfolder, Settings): """Checks if it should comment on the image""" # check action availability if quota_supervisor(Settings, "comments") == "jump": return False, "jumped" rand_comment = random.choice(comments).format(username) rand_comment = emoji.demojize(rand_comment) rand_comment = emoji.emojize(rand_comment, use_aliases=True) open_comment_section(browser, logger) comment_input = get_comment_input(browser) try: if len(comment_input) > 0: comment_input[0].clear() comment_input = get_comment_input(browser) # below, an extra space is added to force # the input box to update the reactJS core comment_to_be_sent = rand_comment + " " browser.execute_script( "arguments[0].value = arguments[1];", comment_input[0], comment_to_be_sent, ) # below, it also will remove that extra space added above # COS '\b' is a backspace char in ASCII comment_input[0].send_keys("\b") comment_input = get_comment_input(browser) comment_input[0].submit() update_activity(Settings, "comments") if blacklist["enabled"] is True: action = "commented" add_user_to_blacklist( username, blacklist["campaign"], action, logger, logfolder ) else: logger.warning( "--> Comment Action Likely Failed!" "\t~comment Element was not found" ) return False, "commenting disabled" except InvalidElementStateException: logger.warning( "--> Comment Action Likely Failed!" "\t~encountered `InvalidElementStateException` :/" ) return False, "invalid element state" logger.info("--> Commented: {}".format(rand_comment.encode("utf-8"))) # get the post-comment delay time to sleep naply = get_action_delay("comment", Settings) sleep(naply) return True, "success"
Example #5
Source File: RobotAppEyes.py From Robot-AppEyes with Apache License 2.0 | 4 votes |
def check_eyes_region_by_selector(self, selector, value, name, includeEyesLog=False, httpDebugLog=False): """ Takes a snapshot of the region of the element found by calling find_element(by, value) from the browser using the web driver and matches it with the expected output. With a choice from eight selectors, listed below to check by. Arguments: | Selector (string) | This will decide what element will be located. The supported selectors include: CSS SELECTOR, XPATH, ID, LINK TEXT, PARTIAL LINK TEXT, NAME, TAG NAME, CLASS NAME. | | Value (string) | The specific value of the selector. e.g. a CSS SELECTOR value .first.expanded.dropdown | | Name (string) | Name that will be given to region in Eyes. | | Include Eyes Log (default=False) | The Eyes logs will not be included by default. To activate, pass 'True' in the variable. | | HTTP Debug Log (default=False) | The HTTP Debug logs will not be included by default. To activate, pass 'True' in the variable. | Example: | *Keywords* | *Parameters* | | Open Browser | http://www.navinet.net/ | gc | | | | | | Open Eyes Session | http://www.navinet.net/ | RobotAppEyes_Test | NaviNet_RobotAppEyes_Test | YourApplitoolsKey | 1024 | 768 | | Check Eyes Region By Selector | CSS SELECTOR | .first.expanded.dropdown | NaviNetCssElement | | | | | Close Eyes Session | False | | | | | | """ if includeEyesLog is True: logger.set_logger(StdoutLogger()) logger.open_() if httpDebugLog is True: httplib.HTTPConnection.debuglevel = 1 searchElement = None if selector.upper() == 'CSS SELECTOR': searchElement = By.CSS_SELECTOR elif selector.upper() == 'XPATH': searchElement = By.XPATH elif selector.upper() == 'ID': searchElement = By.ID elif selector.upper() == 'LINK TEXT': searchElement = By.LINK_TEXT elif selector.upper() == 'PARTIAL LINK TEXT': searchElement = By.PARTIAL_LINK_TEXT elif selector.upper() == 'NAME': searchElement = By.NAME elif selector.upper() == 'TAG NAME': searchElement = By.TAG_NAME elif selector.upper() == 'CLASS NAME': searchElement = By.CLASS_NAME else: raise InvalidElementStateException('Please select a valid selector: CSS SELECTOR, XPATH, ID, LINK TEXT, PARTIAL LINK TEXT, NAME, TAG NAME, CLASS NAME') eyes.check_region_by_selector(searchElement, value, name)