Reputation: 161
I want to set a value in editbox of android app using appium. And I am using python script to automate it. But I am always getting some errors.
My python script is
import os
import unittest
import time
from appium import webdriver
from time import sleep
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
import uiautomator
import math
element = self.driver.find_element_by_class_name('android.widget.EditText')
element.set_value('qwerty')
element = self.driver.find_element_by_name("Let's get started!")
element.click()
time.sleep(5)
When ever I am running it, I am always getting an error:
AttributeError: 'WebElement' object has no attribute 'set_value'
Upvotes: 4
Views: 9490
Reputation: 621
To type a value into a WebElement, use the Selenium WebDriver method send_keys
:
element = self.driver.find_element_by_class_name('android.widget.EditText')
element.send_keys('qwerty')
See the Selenium Python Bindings documentation for more details.
Upvotes: 4
Reputation: 1129
It's as simple as the error: The type element is, has no set_value(str) or setValue(str) method. Maybe you meant
.setText('qwerty')?
Because there is no setText method in a EditText widget: http://developer.android.com/reference/android/widget/EditText.html
Upvotes: -1