How to automate Google Play Update App popup using Appium - 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()

Related

How can I take a screenshot of an alert using Selenium webdriver in Ruby?

Hi I'm a new user of selenium. I'm trying to take a screenshot of an alert using selenium webdriver in ruby.
#driver.find_element(:name, "updateButton").click
#driver.save_screenshot "./#{Time.now.strftime("Alert_Screenshot___%d_%m_%Y__%H_%M_%S")}.png"
Instead of taking a screenshot, this error is thown:
Selenium::WebDriver::Error::UnhandledAlertError
Of course I can accept the alert:
#driver.switch_to.alert.accept
and then take a screenshot. But I want to know is there way to take the screenshot while the alert is being prompted?
In your case you need to take screenshot for complete screen, not only the browser. So you can use xwd to take a screenshot of the root window:
xwd -display :0 -root|xwdtopnm |pnmtopng > $1

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.

Standard print button is inoperative in custom Report

My customer has reported a problem that standard ''print'' button in Z-report which a developer wrote before is not working.
How can I enable the button?
MODULE user_command_0100 INPUT.
DATA: GS_STATUS TYPE SLIS_STATUS,
XS_STATUS LIKE GS_STATUS.
CASE sy-ucomm.
WHEN 'BACK' OR '%EX' OR 'RW'.
LEAVE TO SCREEN 0.
WHEN '&RNT'.
ENDCASE.
ENDMODULE.
Then button needs a usercommand assigned, which is then processed in pai. usually with a general form called get_ucomm (many developers call it similar). You also can issue /h in transaction field and then press the print-button. /h will trigger the debugger and You can inspect the report step by step.
That's all I can say without seeing the code. Hope this will help.
Which user command do you define in your GUI status?
If you have a standard list (what I expect when you write about a z-report), then you should define the command PRI to print the list:
If you define a screen (using the screen painter) or an ALV-Grid... then this solution will not help you.
If you don't know, what a GUI status is: Scan your source code for the command
SET PF-STATUS 'XXXX'.
Then double click on 'XXXX' and you should be directed to the status definition. There may by multiple status (and status with generic names).
I've seen your code and for the &RNT option there's no code to execute, so if the user wants to print the button will do nothing.
MODULE user_command_0100 INPUT.
DATA: GS_STATUS TYPE SLIS_STATUS,
XS_STATUS LIKE GS_STATUS.
CASE sy-ucomm.
WHEN 'BACK' OR '%EX' OR 'RW'.
LEAVE TO SCREEN 0.
WHEN '&RNT'.
" There's no code
ENDCASE.
ENDMODULE.
I've used the 'STANDARD' GUI Status from the function group 'KKBL' and '&RNT' is the code of the print button and that's why I think that is the print button you are refering in your program.
Can you post the GUI Status you are using please?

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

having problem in blackberry

I am doing coding from beggining blackberry by Anthony Rizk.
I am stuck with this code as it is showing error again and again...
private void getURL() {
HttpRequestDispatcher dispatcher = new HttpRequestDispatcher(urlField.getText(),
"GET", this);
dispatcher.start();
}
Can anyone explain me why we are passing this as parameter and why actually this code is doing...
"this" refers to the main screen you passed to the class so you can alert the requestFailed string. Check the run method on page 170. You'll see screen.requestFailed("Unexpected...").
As for your error - I suggest adding this line:
System.out.println(" ----------------- HTTPREQUESTDISPATCHER ---------- " + urlField.getText());
right before your dispatcher.start(); line and then compile in debug mode to see what your console says. Just to make sure your URL to request is a valid web URL.
Additionally, make sure your simulator has MDS enabled. You need that to make web calls.
In eclipse it is under Run->run configurations-> simulator tab -> general -> checkbox for Mobile Data System.
I don't know where it is in the RIM package. If you're not using eclipse, you might want to switch over to it. It will highlight errors and try to help you resolve them.

Resources