Good afternoon Community,
I'm using Cucumber in Eclipse to run automated tests on an application installed on an Android that is in a VM, namely housed in the Perfecto Lab website. Perfecto Lab has several functions that we can call in eclipse, for example back to homescreen , swipe, among others. A function that I consider important that does not exist, is the function to click on the Android Back button. The tests are done 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 on a button and at the end, click on the android back button 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 role that 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 is happening when I try to run the test, it does all the steps without errors, the problem is that it is not going back. The code has commented lines, so you can see what I have already tested. I have the feeling that I'm on the right track, I do not know if I'm initializing the variable badly.
The goal was to make the back button function work.