Hello Experts,
I Have a app where I m stuck in ‘Buy Tickets’ screen ,here In this screen there are many passes but out of all these passes i have to tap on one particualr pass, the index and names are unique for these passes, but the ‘+’ button next to all of these passes, they also have index numbers but all have been assigned value of 2, how should i tap on the '+'button (they are named as ‘Add to cart’)
I am attaching the screenshot from uiautomatorviewer for the app with xml ,if an body can just let me know how should i tap on a particular element, Please note the passes are not tappable and only on the ‘+’ button user can tap,
Here is the script:
package androidApp;
import java.net.MalformedURLException;
import java.net.URL;
import java.sql.Driver;
import java.util.List;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import io.appium.java_client.MobileElement;
import io.appium.java_client.TouchAction;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.remote.MobileCapabilityType;
public class MartaApp {
@Test
public void test() throws MalformedURLException
{
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability("app", "/Users/xyz/Downloads/appname.apk");
cap.setCapability("platformName", "android");
cap.setCapability("deviceName", "Nexus 6P");
cap.setCapability("platformVersion", "6.0.1");
cap.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, "100");
AndroidDriver driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"),cap);
driver.manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS);
driver.findElement(By.className("android.support.v7.widget.RecyclerView"));
driver.findElement(By.id("xyzpackagename<img src="/uploads/default/original/2X/5/5a539c64c718a98d023b6f8819f73ff3aee10180.png" width="690" height="397">:id/tileTitle")).click();
//The below code will print whether its native or hybrid view
Set<String> ContextNames = driver.getContextHandles();
for(String contextNames : ContextNames)
{
System.out.println(contextNames);
}
/WebElement a= driver.findElementByXPath("//*[@class='android.widget.RelativeLayout'[@text='1-Day Pass'and @index ='2']");
a.click();