Reputation: 33
I am trying to send data to a login textbox but when I use 'send_keys' I get an error..
def wait_for_element(selenium, selenium_locator, search_pattern, wait_seconds=10):
elem = None
wait = WebDriverWait(selenium, wait_seconds)
try:
if (selenium_locator.upper() == 'ID'):
elem = wait.until(
EC.visibility_of_element_located((By.ID, search_pattern))
)
except TimeoutException:
pass
return elem
userid=os.environ.get('userid')
wait_for_element(selenium, "ID", 'username')
assert elem is not None
elem.click()
time.sleep(3)
elem.send_keys(userid)
tests\util.py:123: in HTML5_login elem.send_keys(userid) ..\selenium\webdriver\remote\webelement.py:478: in send_keys {'text': "".join(keys_to_typing(value)),
value = (None,)
def keys_to_typing(value): """Processes the values that will be typed in the element.""" typing = [] for val in value: if isinstance(val, Keys): typing.append(val) elif isinstance(val, int): val = str(val) for i in range(len(val)): typing.append(val[i]) else: for i in range(len(val)):
for i in range(len(val)):
E TypeError: object of type 'NoneType' has no len()
I have no clue why it is saying the element is of "NoneType" when I have it pass an assertion as well as click the element. I can even see it clicking the element when I run the test!
Upvotes: 2
Views: 1170
Reputation: 193058
This error message...
elem.send_keys(userid) ..\selenium\webdriver\remote\webelement.py:478: in send_keys {'text': "".join(keys_to_typing(value)), value = (None,)
TypeError: object of type 'NoneType' has no len()
...implies that send_keys()
method encountered an error when sending the contents of the variable userid.
Though you have tried to use the variable userid, I don't see the variable userid being declared anywhere within your code block. Hence you see the error:
TypeError: object of type 'NoneType' has no len()
Initialize the userid variable as:
userid = "Austin"
Now, execute your test.
Upvotes: 1