Hi,
I am testing a web application on real android device using appium.
Have a auto suggestive field, when I type some text, it gives auto suggestions.
I want to ignore the suggestions, hide the suggestions and click on the button.
I am appending the code and the screenshots. Please help me with the issue.
Code:
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import io.appium.java_client.PerformsTouchActions;
import io.appium.java_client.TouchAction;
import io.appium.java_client.remote.MobileCapabilityType;
public class TravelexMobileTestCode
{
static DesiredCapabilities cap = new DesiredCapabilities();
static TouchAction t;
static WebDriver driver;
public static void main(String[] args) throws InterruptedException, MalformedURLException {
// TODO Auto-generated method stub
cap = new DesiredCapabilities();
//cap.setCapability(MobileCapabilityType.DEVICE_NAME, "Nexus5API25");
cap.setCapability(MobileCapabilityType.DEVICE_NAME, "VIBE K5 Note");
cap.setCapability(MobileCapabilityType.PLATFORM_NAME,"Android");
cap.setCapability(MobileCapabilityType.PLATFORM_VERSION,"6.0");
//cap.setCapability(MobileCapabilityType.PLATFORM_VERSION,"7.1.1");
cap.setCapability(MobileCapabilityType.BROWSER_NAME,"chrome");
cap.setCapability(MobileCapabilityType.NO_RESET, true);
cap.setCapability(MobileCapabilityType.FULL_RESET, false);
cap.setCapability("unicodeKeyboard", true);
cap.setCapability("resetKeyboard", true);
//cap.setCapability("appPackage","com.android.webview.chromium");
//cap.setCapability("appActivity", "com.android.webview.chromium.LicenseActivity");
driver = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"),cap);
driver.get("https://www.travelex.com.au/");
System.out.println(driver.getTitle());
//WebDriverWait wd = new WebDriverWait(driver,20);
WebElement DestCcyCnty = driver.findElement(By.name("currency"));
DestCcyCnty.clear();
DestCcyCnty.sendKeys("Si");
List<WebElement> CcyOptions = driver.findElements(By.className("ui-menu-item"));
Thread.sleep(2000);
for(int CcyOption=1;CcyOption<=CcyOptions.size();CcyOption++)
{
if(CcyOptions.get(CcyOption).getText().contains("SGD"))
{
CcyOptions.get(CcyOption).click();
break;
}
else
if(CcyOptions.get(CcyOption).getText().contains("No matches found."))
{
System.out.println("No currencies are found matching with the search");
break;
}
}
Thread.sleep(1000);
driver.findElement(By.cssSelector(".addCash")).click();
//Bpay selection
driver.findElement(By.id("order-paymentItem-focus-span-bPay")).click();
//Store search field
WebElement StoreField = driver.findElement(By.id("searchTerm"));
//t = new TouchAction((PerformsTouchActions) driver);
//t.press(StoreField).
StoreField.clear();
StoreField.sendKeys("Melbourne, Victoria, Australia");
Thread.sleep(1000);
System.out.println(driver.getPageSource());
driver.findElement(By.id("bothPickupLabel")).click();
//Find a Store button
WebElement findStore = driver.findElement(By.id("searchBtn"));
findStore.click();
Screenshot with auto suggestions:
Screenshot after hiding the auto suggestions: (I need to click on ‘Find a store’ button)