Issue
I've located all inputs on a create form with on my application by:
_inputs =find_elements_by_xpath("//form[@id='createForm']//input")
and I got my list of values that I need to input :
_data = ['selenium', 'selenium test', 'John Dow']
what I'd like to do is to send keys to each of those webelements from list using a loop, what I wrote
for x in range(len(self._data)):
try:
_inputs[x].send_keys(self._data[x])
except Exception:
continue
finally:
_all_inputs[0].send_keys(Keys.RETURN)
sending RETURN should trigger the submission of the form
but I'm getting selenium.common.exceptions.ElementNotVisibleException: Message: Element is not currently visible and so may not be interacted with
When I'm sending keys individually it's not an issue but well that's not what I'm trying to do here.
Solution
You can use visibility_of from expected_conditions
to make sure the element is visible
wait = WebDriverWait(driver, 10)
for x in range(len(self._data)):
try:
wait.until(expected_conditions.visibility_of(_inputs[x]))
_inputs[x].send_keys(self._data[x])
except Exception:
continue
finally:
_all_inputs[0].send_keys(Keys.RETURN)
Answered By - Guy
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.