Hello Guys,
In my last blogs, we discussed about appium setup and launching of an app and finding web elements using appium so that we can perform any operation using those web elements. Say we want to click any button like we did in our Calculator example where we performed 7 + 5 = 12 operation successfully.
So far we have only seen to perform click() operations. It’s pretty simple, just find the element like Buttons, checkbox, radio buttons etc., call the click() method with that web element.
For e.g.,
WebElement loginbtn = driver.findElementById("com.tinder:id/button_login_real"); loginbtn.click();
It’s really very simple....isn’t it ?? Now, what if we want to enter some text say login id, password or
some comments ? Well, for that we need to call “sendKeys()” method. We pass the text which we
want to enter to the respective web elements. It’s a good practice though, to save your contents in a
variable and pass the variable to this method. In the following example we will see how to pass login ID
and Password to an app. For e.g., public final String EMAIL = "myname@gmail.com", PASS = "MyPassword"; driver.findElement(By.xpath("//android.widget.EditText[@index='0']")).sendKeys(EMAIL); driver.findElement(By.xpath("//android.widget.EditText[@index='1']")).sendKeys(PASS); And once we have entered the credentials, we can click the login button. So, now we can easily signup,
login to any app which require thses stuffs. Isn’t it Cool ?? Okay, So the concept says, Get that element
which you want to perform action upon and just perform the action. This Click() method can be applied
not only with Buttons, but Radio Button, CheckBoxes, or even Toggle Buttons. All it requires is the
finding that element. That’s it !! If you are confused with any of the things mentioned here in this blog.
I recommend you to go through my previous blogs on appium where I have mentioned these things in
details.
