0
Good afternoon Commonwealth,
I am using Cucumber in Eclipse to elaborate automated tests on an application installed on an Android that is on a VM, namely hosted on the site Perfecto Lab. Perfecto Lab has several functions that we can call in the eclipse, for example, return to the homescreen, make Swipe, among others. One function that I consider important that does not exist, is the function to click the Back button of Android. The tests are performed in Cucumber, but the functions are created in java. I am also working with appium if it is relevant to solving my problem.
This is the code corresponding to the test to be performed. Open the application, click a button and at the end, I would click the back button of android to go back.
@MyAxa_Spain_Login
Feature: Customer without car contracts tries to consult his car contracts
@Start_app_and_Login
Scenario: launch APP
Given I start application by name "My AXA España"
Then I click on "button.aceder"
And wait until "button.username" to be visible
And I wait for "5" seconds
Then I Click Back
This is my function I’m trying to implement to click the back button of android.
@QAFTestStepProvider
public class BackKey {
@Then("^I Click Back")
public void clickBack() {
//AppiumDriver<WebElement> driver;
AndroidDriver<WebElement> driver;
PerfectoDeviceSteps getSteps = new PerfectoDeviceSteps();
String host = "https://atc.perfectomobile.com/nexperience/perfectomobile/wd/hub";
//PerfectoDeviceSteps getSteps = new PerfectoDeviceSteps();
//getSteps.goToHomeScreen();
try {
//DesiredCapabilities capabilities = new DesiredCapabilities("", "", Platform.ANY);
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("user", "[email protected]");
capabilities.setCapability("password", "passfake");
//capabilities.setCapability("deviceName", "CE12160C43D92A0704");
driver=new AndroidDriver<WebElement>(new URL(host), capabilities);
//((AndroidDeviceActionShortcuts) driver).pressKeyCode(AndroidKeyCode.BACK);
((AndroidDriver<WebElement>) driver).pressKeyCode(4);
System.out.println("chega aqui");
getSteps.takeScreenshot();
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
What’s happening when I try to run the test, it takes all the steps without mistakes, the problem is it’s not going back. The code has commented lines, so you can see what I’ve already tested. I have a feeling I’m on the right track, I don’t know if I’m initializing the variable wrong.
The goal was to get the back button function to work.