Appium Desktop recorder is using Xpath instead of Id - appium

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']"))

Related

How to record screen while testing in Robot framework Appium?

I'm looking the way how to record screen on Robot framework Appium.I've check on Appium Robot Framework Doc but it doesn't describe about it but i have try to write custom lib with python but it's doesn't support.
import os
import subprocess
from appium import webdriver
from robot.api import logger
desired_caps = {}
desired_caps['platformName'] = 'iOS'
desired_caps['platformVersion'] = '12.3.2'
desired_caps['bundleId'] = 'xxxxxx'
desired_caps['udid'] = 'xxxxxxx'
desired_caps['deviceName'] = 'iPhone'
driver = webdriver.Remote("http://localhost:4723/wd/hub",desired_caps)
def start_screen_recording():
driver.start_recording_screen()
def stop_screen_recording():
filepath = os.path.join("/Users/keo.sidara/Desktop/Mobile_Test/testcases/regression", "screen_recording_110918-205655.mp4")
warning_message(filepath)
payload = driver.stop_recording_screen()
with open(filepath, "wb") as fd:
fd.write(base64.b64decode(payload))
and i got message
[W3C] Matched W3C error code 'invalid session id' to NoSuchDriverError
[W3C (1530275d)] Encountered internal error running command:
NoSuchDriverError:
Anybody experience with it ? please share me. Thanks
The Appium documentation on the start Recording method is here.
In the AppliumLibrary documentation the source code for keyword Open Application shows that the keyword returns number of the application in the registry.
This means that there is no AppiumLibrary supported way of retrieving the webdriver. This means that a modification to the original library is needed. This has been done already in a fork: nichotined / robotframework-appiumlibrary
Removing the original library from your python installation and installing this one, you then have access to the keyword Get Current Application that returns the driver. Now, you can use the below approach or add another keyword yourself in the same fashion to create the custom Start and Stop Screenrecording.
As I don't have a working Appium Setup, I'm unable to validate this myself:
*** Settings ***
Library AppiumLibrary
*** Test Cases ***
Open Application
... http://localhost:4723/wd/hub
... alias=Myapp1
... platformName=iOS
... platformVersion=7.0
... deviceName='iPhone Simulator'
... app=your.app
${driver} Get Current Application
Call Method ${driver} start_recording_screen
As of robotframework-appiumlibrary v1.5.0.6, support for screen recording has been implemented. Can check https://serhatbolsu.github.io/robotframework-appiumlibrary/AppiumLibrary.html#Start%20Screen%20Recording.
Happy Coding!
I've never used Robot Framework before but I tried a lot of ways to record with the appium driver but I couldn't get it working. The only solution that I found was to use ADB SHELL Commands to record the screen of a device. You should have in mind that not all devices are capable of getting their screen recorded.
adb shell screenrecord /sdcard/test.mp4 --size 480x720 #To start recording
Once you kill the process above you can get the video from the device with these commands
adb pull /sdcard/test.mp4 "C:/"
adb shell rm /sdcard/test.mp4

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.

InvalidPrintCommand error when calling SalReportPrint() function

The application was written in TD 6.2 version. When trying to print using builtin function SalReportPrint()-InavlidPrintCommand error has been received. I have already tried Menu Report->Format->Report option( qrp file) and selected the check box use defult printer option but still getting same error.
had this case several times, using an older version of TD (4.1).
There my problem was that either the printer which it reported that it should be printing on was not installed or it wasn't set as a default printer.
Try to set your printer of choice to be default printer, using SalPrtSetDefault() before you do the printing action.

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.

sendkeys command causing exception in selenium webdriver on IOS safari

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

Resources