I am trying to utilize RIDE and Robot framework with appium for mobile testing and I am unable to get appium/sauce to recognize the locators we used for our browser platform testing. It is a web based app so all of the locators should be the same and I am unsure of the syntax required for RIDE to utilize the appium library. I have added the sauce log as well as what I currently have in robot framework. We are able to get the app loaded, the login screen loaded and then fail out when it tries to input a login name/password.
https://saucelabs.com/tests/1b762e1a7d2f4fc694bd0957f7d0d1b1
appiumlibrary.open application http://test#localhost:4445/wd/hub platformName=android platformVersion=5.0\appiumversion=1.4 \ deviceName=android emulator app=test-url.apk device-orientation=portrait
sleep 30
Input Text xpath=//*[#id=login-inner] test
Input Text //*[#test-id='fldPassword'] test
Click Element //*[#class='ember-view pointer login-btn logon-submit btn btn-primary submitButton form-validation-submit submit is-valid']
Related
I am searching for a test automation tool that supports the following test case:
start an app on the smartphone
click on a button; the click on the button starts the browser and opens a web page in the browser, on the smartphone of course
enter some data in the browser
return to the app: the entered data must be visible now in the app
I have seen many test automation tools, that support app testing and browser testing. But there I have seen only situations where the browser is opened on the computer where the test automation tool runs; or cases where the browser is started separately on a smartphone.
Does anyone know a tool that supports testing the described communication between the app and the browser which was started by the app?
This can be done in the standard automated UI testing that comes with Xcode, XCUITest (i'm assuming the Android equivalent can do the same). I'm a fan of using the inbuilt stuff as you get full access to Swift/Objective-C and don't have to deal with any additional, buggy dependencies
E.g. I had a settings screen in an app that had multiple links to external resources. I had an automated test that tapped the buttons, waited a few seconds, then verified that safari contained the correct URL, then returned to the app.
Your usecase will obviously be more involved than mine, but here is a sample of navigating from app -> Safari -> interact with safari -> return to app
func test_ExternalLinks() {
// Hold onto a reference of our app that we are testing, and safari installed on the phone
let app = XCUIApplication()
let safari = XCUIApplication(bundleIdentifier: "com.apple.mobilesafari")
// Query to get safari URL textfield
let urlTextField = safari.textFields["URL"]
// Navigate to settings screen
...
...
// Tap "About" button in our app
app.tables.staticTexts["About"].tap()
sleep(2)
// Tap URL bar so we can examine the full URL
safari.buttons["URL"].tap()
urlTextField.tap()
// Extract URL and compare to known value
var url = urlTextField.value as! String
XCTAssert(url == "https://...../about/", url)
// Return to our app
app.activate()
sleep(2)
}
I'm setting up test automation for an Android app using Appium. I can launch the Android app, find elements, enter text and click buttons. The issue I have is that my app has a user login, which requires launching a web browser to a web page from Identity Server (https://github.com/IdentityServer). For discussion purposes, this is a web page with entry fields for login and password with a sign in button.
So the automated process is:
Launch app
Enter url for login page (i.e. identity server) in text field
Click save button (to save setting)
Click login button, which opens web browser to login page (after successful login, control returns to the app.)
Here is where I am stuck. How can I use Appium to find the text controls and enter login and password, then find and click "Sign in" button for webpage (which will redirect back to the Android app under test and continue with remainder of automated app tests.)?
Appium's Inspector will only find a view from com.sec.android.app.sbrowser. It does NOT find any of the browser elements. Same with Android's UI Automator Viewer.
Anyone have any ideas?
You need to switch your context from native app to webview.
Here how I implemented it in tests.
In some Page Object files I keep Android contexts.
ANDROID_CONTEXTS = {
'webview': 'WEBVIEW_ru.myapp',
'native': 'NATIVE_APP'
}
In some tests I switch context from Native to Webview.
#allure.link(url='https://jira.project.tech/browse/TEST-1', name='TEST-1 - Fill payment form')
#allure.title('Fill payment form')
def test_card_standard_1_month(appdriver):
Paywall(appdriver).press_one_month_button()
PaymentsPage(appdriver).select_card_payment()
PaymentsPage(appdriver).press_payment_button()
appdriver.switch_to.context(ANDROID_CONTEXTS['webview'])
Payform(appdriver).fill_and_submit_payform()
appdriver.switch_to.context(ANDROID_CONTEXTS['native'])
assert SuccessPayment(appdriver).get_successful_payment_title_text() == 'Your subscription is successful!'
You can check all available contexts in your app. More info here -> http://appium.io/docs/en/commands/context/set-context/
I've trawled the internet but can't find anything specific to help me. I'm not overly-technical so please go easy with your answers (ha ha).
I am trying to create a very basic script that goes to a specific URL on a virtual device, enters a username and a password and logs in.
I take the following steps:
Start Appium server
Run Test
I've tried both of these as approaches for kicking up my instance of chrome on the Android Virtual Device:
Open Application ${global_appiumEndpoint}
... udid=emulator-5554
... platformName=Android
... androidPackage=com.android.chrome
... platformVersion=10
... deviceName=Google Pixel 2
... browserName=Chrome
... chromedriverExecutableDir=//AutomationDrivers//OLD
... fastReset=true'''
If I try and interact with the google chrome session created using selenium commands, I get an error of "No browser is open" (even though it is??!), however, commands from the appium library do seem to work (but are not sufficient for my testing)
If I try and kick up an instance of Chrome using this approach:
${capabilities}= Create Dictionary
Set to dictionary ${capabilities} udid emulator-5554
Set to dictionary ${capabilities} platformName Android
Set to dictionary ${capabilities} platformVersion 10
Set to dictionary ${capabilities} deviceName Google Pixel 2
Set to dictionary ${capabilities} browserName Chrome
Set to dictionary ${capabilities} chromedriverExecutableDir //AutomationDrivers//OLD
Set to dictionary ${capabilities} fastReset true
Set to dictionary ${capabilities} app com.android.browser
Create Webdriver Remote command_executor=http://localhost:4723/wd/hub desired_capabilities=${capabilities}
I get told that no application is open (which it is!).
So
What am I doing wrong?
Is it possible for selenium and appium commands to co-exist on the same test because I'm beginning to doubt my sanity!!
Thanks all
One thing is an Android App, the other is an Android Operating System App, like Chrome. The error you have is that there is no App started, because you did not provide an APK, or class path for an App.
When wanting to use SeleniumLibrary to do web testing with AppiumLibrary, you have to Switch context to Web testing (and from Web testing to App testing). There is appropriate keyword in AppiumLibrary, for this.
In your test script, to avoid libraries keyword names conflicts, you have to prefix with the intended one. For example: SeleniumLibrary.Capture Page Screenshot.
I recommend to try the Appium/AppiumLibrary "OrangeDemo" to start an App from APK.
After refreshing my knowledge on using Chrome with AppiumLibrary, I made a basic example:
*** Settings ***
Library AppiumLibrary run_on_failure=AppiumLibrary.Log Source
*** Test Cases ***
Open robotframework.org
[Documentation] Simple demo of opening Chrome, going to robotframework.org and capture a screenshot.
Open Application http://localhost:4723/wd/hub platformName=Android platformVersion=8.1 deviceName:emulator-5554 browserName=Chrome automationName=UIAutomator2
Switch To Context CHROMIUM
Go To Url https://robotframework.org/
Capture Page Screenshot
Close Application
Things to know:
Before starting server from AppiumDesktop, you need to add in settings the full path to the executable of chromedriver (i.e. chromedriver.exe).
To start Chrome on browser, use browserName=, for apps there are different options like, app=<path_to_APK>, appPackage= and appWaitActivity=, also automationName=UIAutomator2 is the more recent for Android.
I want to use Appium to automate the scenario below on Android
First open a web page in Chrome. The web page contains a
registration form
Fill the form then click the submit button
The submit button open my native app via the uri (the same behavior
as we open the Google Play by clicking on a link market://...)
Finally interact with the app
I could make the automation for step 1 to 3 but stucked at step 4.
Is this possible with Appium? Is there any other testing framework which can automate the scenario like that?
It seems that the problem is related to changing from the webview context to the native app's own context. This is done in Java by using the command driver.context("NATIVE_APP");
To view all available contexts use driver.getContextHandles();, which returns a Set<String> with all available contexts.
Native context is always called "NATIVE_APP" and webviews usually are indexed as "WEBVIEW_0", "WEBVIEW_1" and so on.
All interactions to the app that are not related to a webview directly, will usually need to be done while in "NATIVE_APP" context.
It seem you have timeout exception, just change your code from driver.find_element(By.id("my_button_id"))
to
WebDriverWait(driver, 10).until(lambda:driver.find_element(By.id("my_button_id")))
I'm trying to integrate Twitter sharing functionality into my Android PhoneGap application, and rather than re-implement the controls to shorten URLs and track tweet length, I thought I'd use their premade web intents at https://twitter.com/intent/...
So I'm trying to launch a URL like https://twitter.com/intent/tweet?text=Hello in a ChildBrowser window, so that I can let Twitter's interface take over. The user could sign in with their credentials, and once they're signed in, the text from the URL params would appear in the Tweet box.
It won't work. When I use http://twitter.com/intent/... instead of https://twitter.com/intent/... , ChildBrowser displays the sign-in screen, but as soon as the user submits their credentials, the screen goes white. I suspect this is because Twitter switches over to HTTPS.
I confirmed that this was the case by trying a simple window.open instead of window.plugins.childBrowser.showWebPage. I have no problems with HTTP / HTTPS when using the native browser on Android. However, the native browser prompts me to accept an unverified security certificate. I suspect this is the problem with ChildBrowser - it doesn't know how to handle that prompt.
Using the native browser popover simply isn't an option: the user needs to be able to exit the process after hitting 'Tweet' or 'Follow', etc., but the 'back' button on the Android device simply moves the history one step backward to the POST action for their intent. Then, it re-launches the app from scratch, instead of returning you to the original state.
How can I configure ChildBrowser / my Android Phonegap application to override SSL issues on Twitter, so that I can run web intents in Childbrowser?
The relevant code is:
base="https://twitter.com/intent/tweet?text=";
URL=base+encodeURIComponent("it works!");
// works, but asks to accept a certificate
window.open(URL);
// blank white page
window.plugins.childBrowser.showWebPage(URL, { showLocationBar: true });
My cordova.xml file has whitelists configured as such:
<access origin="http://127.0.0.1*"/> <!-- allow local pages -->
...which I don't suspect should be a problem. However, a basic test of swapping origin=".*" yielded no change in behaviour.
I've also examined the HTTP and HTTPS headers for the Twitter intent landing pages. There doesn't appear to be anything out of line - they're identical, except for the Strict-Transport-Security header for HTTPS, which works elsewhere (e.g. Github).
Please help!
The ChildBrowser is not bound by the whitelist. The whitelist is only used to keep the main PhoneGap app from running code outside of trusted domains.
I'm confident if you go get the latest ChildBrowser code from Android you won't have run into this problem anymore. We've made some changes recently that make it more robust.
Also, Libby has a good tutorial integrating Twitter and the ChildBrowser.
http://www.mobiledevelopersolutions.com/home/start/twominutetutorials/tmt5p1