0

Trying to automate a test on iPad-emulator in the Browserstack-cloud. Many locator strategies that I've tried break with the following exception:

Exception: An element could not be located on the page using the given search parameters

Because I tried many variants I'm quite sure, that my mistake is a general one - but I can't find it. My C# code:

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.SetCapability("device", "iPad Air 2");
capabilities.SetCapability("browserstack.user", browserStackUser);
capabilities.SetCapability("browserstack.key", browserStackKey);
capabilities.SetCapability("name", "ios - actions");

Uri serverUri = new Uri("http://hub.browserstack.com/wd/hub/");
AppiumDriver<IWebElement> driver = new IOSDriver<IWebElement>(serverUri, capabilities, new TimeSpan(1000000000000));
driver.Navigate().GoToUrl("http://www.amazon.de");
driver.Context = "NATIVE_APP";
Thread.Sleep(20000);
IWebElement anyElement = driver.FindElementByName("field-keywords");

What is the general mistake in that approach?

This is the element I try to locate: amazon appium example

else42.de
  • 465
  • 5
  • 23

1 Answers1

1

Can you please post screenshot, so that I can give you location strategy to be used. Also, Instead of GoToUrl you can use get API. The below code is in java.

driver.get(""http://www.amazon.de");
WebDriverWait wait = new WebDriverWait(driver, 30);
wait.until(ExpectedConditions.presenceOfElementLocated(BY-LOCATOR-STRATEGY-HERE)); //wait for page to load before finding any element
WebElement element = driver.findElement(BY-LOCATOR-STRATEGY-HERE);
Suman
  • 436
  • 4
  • 10
  • I added a screenshot. Locator strategy is by name. – else42.de Aug 22 '16 at 07:38
  • @projekt-fisch : I have not used browser-stack for appium automation. But, becuase this is browser so your context can't have NATIVE_APP. This context is used for native apps. Does your test launches the browser and opens the amazon site? If yes, then you can add a wait statement for amazon logo and then click on the search bar. **`wait.until(ExpectedConditions.presenceOfElementLocated(By.id("nav-logo"))); driver.findElement(By.id("twotabsearchtextbox")).sendKeys("TEXT-TO-SEARCH");`** – Suman Aug 22 '16 at 08:53
  • thx. Your answer goes in direction of 'normal' browser automation. But I need to find the element on iPad emulator. – else42.de Aug 22 '16 at 09:43
  • Same wait.untilElement and findElement method can be used to find element on iPad emulator. – Suman Aug 22 '16 at 10:03