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?
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);