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)
}
Related
Good afternoon,
I am trying to automate the following scenario on Android using Kotlin:
Start Appium driver and open React native app (driver1)
Perform some actions on React native app
Create driver2 with chrome options to open chrome and paste deep link there
Deeplink leads to the app automatically (but I suppose the current session uses driver2, not driver1 here)
I need to continue using the app further with driver1 however it is not working and not finding the element which is on the next screen where my deep link leaded me
I am using Appium v1,21,0
Language - Kotlin
App - React-native
I tried the following solutions:
getContext - does not work as this is not a hybrid app but two different mobile apps
startActivity - it actually launching the app from scratch, not continuing (i need to be on a particular screen after deep-link navigation, can't navigate anywhere else flow won't work)
startActivityCommand - this one did not work for me at all (it ignores the command but maybe anyone can give an example of its usage as I might use it wrong)
driver.switchTo().window("0") - did not work
assign to driver2(web) new capabilities - does not work as it is already defined so we cant change it
sessionId - I am not sure how it works exactly yet, but I tried to find a way to assign a driver to the particular session-id and was not successful (looks like AppiumDriver methods do not support it)
Would appreciate any ideas, links, or sources that can help archive the above
Good Day!
Solution that helped:
#AndroidFindBy(xpath = "//android.widget.EditText[#resource-id=\"com.android.chrome:id/search_box_text\"]")
#iOSXCUITFindBy(id = "")
lateinit var chromeURL: MobileElement
var deeplink = <your deeplink>
driver.activateApp("com.android.chrome")
chromeURL.sendKeys(deepLink)
var clickOnDeepLink = driver.findElements(MobileBy.AndroidUIAutomator("new UiSelector().text(\"$deepLink\")"))
clickOnDeepLink[0].click() //here we could not use Keys.ENTER so we just click on the element first in the list - default android google chrome behaviour
So there is no need for several drivers - same driver instance is fine
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'm integrating AppsFlyer with Android Native Application. And I want to use Deferred Deep Linking, when user click landing page ads and download the app and upon first app open the user lands directly on the activity I want.
Link docs: https://support.appsflyer.com/hc/en-us/articles/207032096-Deferred-Deep-Linking-Getting-the-Conversion-Data
But I have not found a way to check that my code is running correctly.
Please help me with this problem
What was working for me is:
Add physical device as a test device in AppsFlyer (here's how to do it)
Enable Debug Mode in AppDelegate.swift in didFinishLaunchingWithOptions
AppsFlyerTracker.shared().isDebug = true
Add AppsFlyer methods in your AppDelegate.swift (as per article)
Remove app (or test build) from physical device
Open Deep Link from physical device, you will be redirected to App Store. Don't install app from the App Store!!! (just close it)
Install app via XCode
After it, on a first install it will call onConversionDataReceived method and the rest staff.
You're going to have to implement the onInstallConversionDataLoaded listener:
public interface AppsFlyerConversionListener {
void onInstallConversionDataLoaded(Map<String,String> conversionData);
void onInstallConversionFailure(String errorMessage);
}
This will return a map of all the parameters on the link that you clicked.
The parameter you need to pay attention to is the af_dp parameter.
This parameter should contain the URI scheme of the activity you want to route your users to. Make sure that you have set up this URI scheme properly in the manifest.
To create a tracking link you can use Link Management. It doesn't matter if it's a single platform link or a OneLink, as long as you have the af_dp parameter on the link, that parameter (along with all other parameters on the link) will be part of the response.
If you're still facing issues, feel free to reach out to support#appsflyer.com.
I have developed a xamarin form app that it uses MS Graph in order to user sign in. I have used samples of GitHub that open a new browser activity where user sign in and then the app goes to home activity. It works correctly. But some users have blocked or deleted Chrome app in order to use MS Edge as default browser, and then when app tries to start the browser activity, it launches an error because it can’t find chrome activity. I have asked on MS Graph GitHub (https://github.com/microsoftgraph/msgraph-sdk-dotnet/issues/242 ) but they and I are thinking that it isn’t problem of SDK but I don’t know how I could fix it. How should I fix it in order to work with any installed browser?
Thank you
It is done by design. The Microsoft Identity Client library uses Custom Chrome tabs and does not have any fallback strategy to run using a WebView.
You are probably encountering this exception thrown when it doesn't find Chrome installed: https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/blob/dev/src/Microsoft.Identity.Client/Platforms/Android/AuthenticationActivity.cs#L131
string chromePackageWithCustomTabSupport = GetChromePackageWithCustomTabSupport(ApplicationContext);
if (string.IsNullOrEmpty(chromePackageWithCustomTabSupport))
{
string chromePackage = GetChromePackage();
if (string.IsNullOrEmpty(chromePackage))
{
throw new MsalClientException(MsalClientException.ChromeNotInstalledError,
"Chrome is not installed on the device, cannot proceed with authentication");
}
#Cheesebaron is correct, this is by design. Currently, Xamarin Android in MSAL can only launch chrome or chrome custom tabs. If the device doesn't have them, it will cause an exception, as you noted above.
#cansado2930 This part of the error message pkg=com.android.chrome means Chrome is not installed on the device.
Embedded webview support in MSAL will be an option in near future.
Here's a link to the issue in the MSAL repo.
After open webpage in app browser where phone number is set I need get phone number in popup for call.
Any plugin for phonegap?
GL
Not sure what your question means, but as far as I understand you need to make a call to the number on button click. Try the following in your HTML file:
<a class="button" href="tel://123456">1234563</a>
If you are getting the number from controller, use:
<a class="button" href="tel://{{number}}">123456</a>
Today I came across a feature request that I had not done before – dialing a number from within an app. Some quick research shows that its possible using a specific URI scheme.
What are URI schemes? Honestly Wikipedia does a better job than I ever could in describing them but I think of them as something that allows a specific piece of functionality to happen over the internet, and thus they are usually referred to as protocols. You probably have already seen them – the most common ones are http: and https: (for web browsing), and ftp:, among others. Some are unique to an application and really don’t qualify as schemes and are definitely not a “protocol”, such as mailto: (to open up the mail client on a person’s computer), javascript: or about: – in fact, try typing about: in the address bar of your browser and hit “enter” on your keyboard, notice what happens…
In our case where we want to dial a number from within our app we need a way of telling the mobile phone that we want to make a call. There is a scheme for this purpose called tel:. A sample number using this scheme would look like this: “tel:+1-800-555-1234”. If you wanted a number to work around the world you would use an international number which includes the country code.
Implementing this is simple, we could do this within our mobile html5 app like so:
...
call this number
...
Ideally though we would delegate the event and fire a function to call our mythical phone number. To send the url (the “tel” url) to the browser we would write the following:
...
document.location.href = 'tel:+1-800-555-1234';
...
As of PhoneGap 3.6 all schemes are subject to whitelists. This means you have to add the tel scheme to a second whitelist that will allow your app to launch external applications. To do this you need to edit your config.XML to include the following (a mailto example is included):
Go here for more information: Cordova 3.6.0 Whitelist Guide.
Of interest to this topic is getting Android to treat phone numbers (as well as URLs and mailto schemes) as clickable links in text fields. I’ve not tested it but try adding the following to your config.xml.
Additional information on this can be found here: http://developer.android.com/reference/android/widget/TextView.html#attr_android:autoLink.
[EDIT: Note that what follows no longer applies but remains here for historical purposes.]
When we run the above code in Android 2.3.6 the phone dialer appears and does so with our number pre-populated ready to be dialed. Unfortunately on iOS 5 this doesn’t happen. A quick review of iOS documentation implies that it should work – so I suppose its just broken.
No need to panic, there is a PhoneGap plugin available which will take care of things. The plugin can be downloaded from here:
Click here to download the iOS Phone Dialer PhoneGap plugin
Its simple to install – just drag and drop the “m” and “h” files on to the classes folder of your xcode project. When you do this a dialog will appear with some options – be sure to click the radio button for copying “…files if needed..”.
Next, update the PhoneGap.plist file to reflect that you are adding a new plugin. The link for downloading the plugin explains the plist values as being “phonedialer > PhoneDialer”… but I think its easier to explain with an image:
The final step is to place the “PhoneDialer.js” javascript file somewhere within the root of your project and then to add it to your index.html file via a script tag.
Now that the Phone Dialer plugin is installed you’ll naturally want to know how to use it:
...
window.plugins.phoneDialer.dial('1-800-555-1234');
...
All in all pretty easy and straight forward, however now you have two methods of dialing a number within a single project. What you want is to use the tel: url scheme in Android and the Phone Dialer plugin in iOS.
Within Sencha Touch we have something called the Ext.is object whose attributes reflect everything that you could possibly want to know about the environment that your mobile app is living within.
For our purposes all we want to know is if we are in iOS or if we are in Android. These two lines provide us the answer:
...
Ext.is.Android // boolean, "true" for android, false otherwise
Ext.is.iOS // boolean, "true" for iOS, false otherwise
...
Thats all we need to impliment phone dialing across the two platforms within our mobile app. Lets build a function that makes use of one of the above (we don’t need both) and we should also give the user a choice in the matter, so the code below includes a message to the user to see if they really do want to suspend the app in favor of the device’s phone dialer:
...
function callSomeone(){
var msg = Ext.Msg.confirm('Please Confirm','Are you sure you want to make a phone call?',
function(r){
if (r == 'yes'){
if (Ext.is.Android){
document.location.href = 'tel:+1-800-555-1234';
} else { // we assume the device is running iOS
window.plugins.phoneDialer.dial('1-800-555-1234');
}
}
});
msg.doComponentLayout();
}
...
All done… I suppose the very last thing to do here is to provide a complete working Sencha Touch example, and some screen captures…
...
Ext.setup({
onReady: function(){
var rootPanel = new Ext.form.FormPanel({
fullscreen: true,
items: [
{
xtype:'button',
text:'Call 1-800-555-1234',
scope:this,
handler: callSomeone
}
],
dockedItems:[
{
xtype:'toolbar',
dock:'top',
title:'Phone Dialer Example'
}
]
}
);
function callSomeone(){
var msg = Ext.Msg.confirm('Please Confirm','Are you sure you want to make a phone call?',
function(r){
if (r == 'yes'){
if (Ext.is.Android){
document.location.href = 'tel:+1-800-555-1234';
} else { // we assume the device is running iOS
window.plugins.phoneDialer.dial('1-800-555-1234');
}
}
}
);
msg.doComponentLayout();
}
}
});
...
From http://rickluna.com/wp/2012/02/making-a-phone-call-from-within-phonegap-in-android-and-ios/