I am using Python in conjunction with Appium to automate testing on an Android mobile device. I am using the Appium/Selenium webdriver and launching Chrome on the device. There is a dialog that I am targeting with a username field and I am able to find the Username textbox via XPath and even click into it to start typing. However when I use the sendKeys() command to enter text into into, it does nothing. Any help will be much appreciated.
Code (Python):
try:
self.prac_btn = self.get_ele('xpath', '//*[@id="dialogMessage"]/fieldset/input[1]')
print "Found username"
except:
print "Cannot find username"
try:
time.sleep(5)
self.click_ele(self.prac_btn)
except:
print "Cannot click on username"
try:
time.sleep(5)
self.prac_btn.send_keys(self, "Username")
except:
print "Cannot type text"
The error is caused by passing two arguments to send_keys()
, which only accepts one argument. self
is not needed as an argument because send_keys()
is a class instance function. self
is passed implicitly.
This is also a good example of why a bare except
is dangerous. If you had caught the exception and printed it, you would have seen something like this:
TypeError: send_keys() takes exactly 1 argument (2 given)
Which would have been a strong clue as to what went wrong.