sendkeys command causing exception in selenium webdriver on IOS safari - ios

I have been trying to run some sample Remote WebDriver tests on the Safari browser on the IOS Simulator 7.0 (IPhone) but my tests give an exception every time I try to type in values on a text box. Just trying to use the example from iosdriver
DesiredCapabilities safari = IOSCapabilities.iphone("Safari");
RemoteWebDriver driver = new RemoteWebDriver(new URL("http://<someip>:4444/wd/hub"), safari);
driver.get("http://hp.mobileweb.ebay.co.uk/home");
WebElement search = driver.findElement(By.id("srchDv"));
search.sendKeys("ipod");
search.submit();
gives me the exception
a "org.openqa.selenium.NoSuchElementException: cannot find element for criteria :{"AND":[{"l10n":"none","expected":"UIAElement","matching":"exact","method":"type"},{"l10n":"none","expected":"Address","matching":"exact","method":"name"}" .
Anyone else run into this? It is identifying the element but typing in values fail..It works fine when I try it on firefox on my desktop.

I am no expert, but am familiar with selenium webdriver..
Are you sure that the id for "search " --- ('srchDv') actually exists on the page you are trying to automate?
if so
i would then look into the UIA -Element Hierarchy / Accessibility link to UIA Element Class reference
Hope this is helpful

You have an incorrect selector. The page you are automating does not have an id srchDv. If you are getting the search box, then you need to use:
driver.findElement(By.id("gh-ac")).clear();
driver.findElement(By.id("gh-ac")).sendKeys("ipod");
Also, instead of using submit, personally i would follow the way that your user would commit the action, and that's by clicking the search button.
driver.findElement(By.id("gh-btn")).click();

Related

How to automate Google Play Update App popup using Appium

I am writing the code line as:
driver.findElement(By.id("com.android.vending:id/0_resource_name_obfuscated")).click();
//Clicking on No Thanks button - resourceid take from Ui Automator
But appium does not respond to this line and give error that no element found.
"An element could not be located on the page using the given search parameters"
Any help? Thanks in advance
Instead of tapping on No Thanks, I used back button
driver.navigate().back();
Query has been resolved with alternate method.
Try to use wait methods :
WebDriverWait wait = new WebDriverWait(driver,30);
wait.until(ExpectedConditions.visibilityOfElementLocated((By.id("com.android.vending:id/0_resource_name_obfuscated")));
//Or use condition: elementToBeClickable()

Appium Desktop recorder is using Xpath instead of Id

I'm exploring my Native App with Appium DeskTop. For an inputfield Appium Desktop is showing in the 'Find By Selector Window' an Id and a XPath expression.
When I recorded a Sendkeys action to this inputfield Appium DeskTop shows in the Recorder Window that the XPath expression is used to locate the Element instead of the Id. This is not what I expected, I expected the Id being used to locate the element.
I tried to use the Id in my Testprogram to locate the element, this is giving, when Explicit waiting for Visbilty of the Element, see C# code below:
wait.Until(ExpectedConditions.ElementIsVisible(By.Id("companyname")));
IWebElement bedrijf = (IWebElement)driver.FindElementById("companyname");
bedrijf.Click();
bedrijf.SendKeys("IBM");
Then the following exception appears:
OpenQA.Selenium.NoSuchElementException
What kind of an Id is presenting Appium Desktop here?
You need to use resource-id. For native android apps, usually id attribute is used as resource-id.
IWebElement bedrijf = (IWebElement)driver.findElement(By.xpath("//android.widget.EditText[#resource-id='companyname']"))

Appium: dealing with android system interactions

I have a simple use-case. Within the android app, press a button and the browser app will open a URL.
The "Open With" dialog pop-up appears and allows you to select Browser or Chrome.
Which looks like this in the appium inspector:
<android.widget.ListView resource-id="android:id/resolver_list">
<android.widget.LinearLayout>
<android.widget.ImageView resource-id="android:id/icon">
<android.widget.LinearLayout>
<android.widget.TextView resource-id="android:id/text1">
<android.widget.LinearLayout>
<android.widget.ImageView resource-id="android:id/icon">
<android.widget.LinearLayout>
<android.widget.TextView resource-id="android:id/text1">
Attempting to automate this seems like it should be trivial, but is causing me trouble. I can get the text of both "Browser" and "Chrome" as discrete AndroidElements, but I cannot seem to be able to actually press the actual options.
Am I allowed to actually interact with these things or is this impossible because it's part of the android system itself?
To help figure this out, here is the setup of my page object.
#AndroidFindBy(id = "android:id/resolver_list")
private AndroidElement listParentElement;
public List<OpenWithOption> getOptions() {
/* ... */
List<MobileElement> elements = listParentElement
.findElementsById(SYS_ID_PREFIX + "text1"); // Here's where I can only get the text element itself but can't figure out how to get the elements above that.
return elements.stream()
.map(mobileElement -> new OpenWithOptionImpl(mobileElement.getText(), mobileElement))
.collect(toList());
}
This was a rookie mistake. Selecting the browser enabled the choice of "Just Once" or "Always" in the bottom of the screen and I didn't notice. I thought that just pressing the browser you wanted would launch it.

Options page not showing

I'm writing a new add-on as a Web Extension. In my package.manifest, I have the options_ui set:
"options_ui": {
"page": "options.html"
}
But in about:addons, the options button is not present.
So I tried to call the page directly from my background script:
runtime.openOptionsPage();
But I get this error:
Message: ReferenceError: runtime is not defined
Same error type with:
chrome.runtime.openOptionsPage();
Message: ReferenceError: chrome is not defined
I'm probably missing something very obvious there. I tested with Firefox ESR 45.0.4 and the latest Firefox Dev edition (51.0a2). How can I get the options page to show in about:addons and how can I call it from my background script?
It's browser.runtime.blah or chrome.runtime.blah.
I'm not sure if ESR 45 supports it.
This code should go in you background script right?
Please post more of your code so i can update my answer.
It turns out that I was mixing Web extensions with Add-on SDK

Unable to findByXpath using Leadfoot / Intern

Using Intern JS with WebDirver to communicate with Appium 1.4.1, I have a simple functional test, part of which should find a text input box on the login screen of our iOS app, tap into it and type the user's login name:
define([
'intern!object',
'intern/chai!assert',
'require'
], function (registerSuite, assert, require) {
registerSuite({
name: 'Suite Name',
'Login Screen': function () {
return this.remote
.setFindTimeout(50000)
.findByXpath("//UIAApplication[1]/UIAWindow[1]/UIAScrollView[1]/UIATextField[1]/UIATextField[1]")
.tap()
.type('student1#demo.com')
.end()
.then(function (pagetitle) {
assert.strictEqual(pagetitle, 'DEMO COLLEGE',
'Should land on app dashboard with school title displayed');
});
}
});
});
When executed using intern-runner everything appears to go well, Appium launches our app and awaits my input - but no matter what I try I can't find the element I need to type into using Leadfoot's findByXpath:
$ intern-runner config=tests/appium
Listening on 0.0.0.0:9000
Starting tunnel...
Initialised iOS on MAC 8.1
Test main - Suite Name - Login Screen FAILED on iOS on MAC 8.1:
NoSuchElement: [POST http://[appium-server-address]:4723/wd/hub/session/80e20453-452e-4181-8713-4f9e0cfa427f/element / {"using":"xpath","value":"//UIAApplication[1]/UIAWindow[1]/UIAScrollView[1]/UIATextField[1]/UIATextField[1]"}] An element could not be located on the page using the given search parameters.
at Server._post <../../.nvm/v0.10.35/lib/node_modules/intern/node_modules/leadfoot/Server.js:68:9>
Using Appium's GUI "inspector" I've confirmed the Xpath to the text-input-box element is:
"//UIAApplication[1]/UIAWindow[1]/UIAScrollView[1]/UIATextField[1]/UIATextField[1]"
Can anyone suggest where I'm going wrong please?
Looks like the Appium Inspector tool on my Mac was duplicating part of the path?
.findByXPath("//UIAApplication[1]/UIAWindow[1]/UIAScrollView[1]/UIATextField[1]/**UIATextField[1]**")
.type("wibble")
Remove the duplicated element in bold (the final UIATextField[1]) ....
.findByXPath("//UIAApplication[1]/UIAWindow[1]/UIAScrollView[1]/UIATextField[1]/**UIATextField[1]**")
.type("wibble")
And it works.
Thanks Appium Inspector. Thanks a lot.

Resources