I am new to QAF. I need to automate both web and mobile app together. Let say, I have to do fund transfer using mobile native app and logout then immediately open desktop browser(Not Mobile browser) and open web application to verify the same transaction.
Since we need to configure both Appium driver and browser driver to achieve this scenario. How to handle this scenario using QAF framework.
With QAF you can interact with multiple device/driver in single testcase. QAF has support for Multiple Devices in one testcase. Driver can be for mobile or desktop browser. Provided capabilities for different drivers you can switch between drivers as required in test case. Assumed that you have provided capabilities for chrome and android driver you can use more than one driver in same test as below:
QAFTestBase testbase = TestBaseProvider.instance().get();
testbase.setDriver("androidDriver");
//some steps with mobile
testbase.setDriver("chromeDriver");`
//some steps with chrome browser instance 1
testbase.setDriver("chrome2Driver");
//some steps with another chrome browser/driver`
testbase.setDriver("androidDriver");`
//switch to do something with mobile driver
testbase.setDriver("chromeDriver");`
//switch to do something with chrome browser instance 1
//tear down test case specific driver session that are no-more required
testbase.tearDown("chromeDriver");
testbase.tearDown("chrome2Driver");
testbase.setDriver("androidDriver");`
//switch back to mobile driver
Related
My usecase involves both Web and mobile devices automation in sequence. The automation flow has certain actions and verifications to be done on Web and later the actions and verifications are to be done on Mobile.
The desired capabilities allow us to select either Chrome or Appium. Is there an example where I can start both Chrome browser and emulator together and run the tests through Serenity and Cucumber?
Need to test responsive design for web app. I understand that browser didn't emulate like real device or even device emulator, but i don't need it.
Note: i'm looking for not to run Safari inside emulator, but to activate mobile emulation in Safari
question 1:
Is it possible to start Safari via selenium with predefined mobile emulation, like in Chrome here
Map<String, String> mobileEmulation = new HashMap<>();
mobileEmulation.put("deviceName", "Nexus 5");
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setExperimentalOption("mobileEmulation", mobileEmulation);
WebDriver driver = new ChromeDriver(chromeOptions);
if answer no(assume it will be no), question 2:
is it enough to resize Safari window to required device viewport size?
Setting the browser width isn't enough as many of today's web pages use the useragent as a means to determine the device that is viewing the page. Afaik, there is no way and I've been trying to find a solution to this for a while. Safari doesn't give automated control to set the user agent nor the mobile mode of its desktop browser.
There is a way to do what you want here though: https://webkit.org/blog/9395/webdriver-is-coming-to-safari-in-ios-13/
But the requirement is you need an iPhone connected to your laptop to run the test from and you need to add these capabilities to your configuration
safari:deviceType
safari:useSimulator
Read the man file for safaridriver for more info.
If you need to set the useragent, you can do it via the command line, but you need to reset it after https://tarunlalwani.com/post/selenium-change-user-agent-different-browsers/
I have a native mobile App and automated by using a Appium Driver (AppiumDriver driver) which is working OK and by one Feature of App e.g. unlock Account send an Email to user which need to be confirmed by User.
So I have find out how to get the link in Email and how to get the URL from send Email.(saved in a String var e.g. "href")
So when the automation run I am in Mobile App in window "INFORMATION" which inform user we have send an Email to confirm.
Now my question is
How can I switch from native mobile App (screen INFORMATION)and Put the URL in Browser and after that should open in Browser a Window which ask user enter new password and repeat it and then press OK ?
After that I should again back to the Mobile App.
Do I need another driver like a Web Driver (additional to appium Driver mentioned above) to handle the Actions in Browser after switch?
Thanks for any Support
This my Capability:
public AppiumDriver<MobileElement> driver;
.....
public DesiredCapabilities cap = new DesiredCapabilities();
.....
cap.setCapability("deviceName", helper.getConfiguration(configFileName, "androidDeviceName"));
cap.setCapability("platformName", helper.getConfiguration(configFileName, "androidPlatformName"));
cap.setCapability("PlatformVersion", helper.getConfiguration(configFileName, "androidPlatformVersion"));
cap.setCapability("automationName", "uiautomator2");
cap.setCapability("MobileCapabilityType.FULL_RESET", android_mct_fullReset);
cap.setCapability("MobileCapabilityType.NO_RESET", android_mct_noReset);
cap.setCapability("appium-version", helper.getConfiguration(configFileName, "appiumVersion"));
cap.setCapability("language", helper.deviceLanguage);
cap.setCapability("locale", helper.deviceLocale);
cap.setCapability(AndroidMobileCapabilityType.UNICODE_KEYBOARD, "true");
cap.setCapability("app", app.getAbsolutePath());
....
driver = new AppiumDriver<MobileElement>(new URL("http://localhost:4723/wd/hub"), cap);
I think this will be achieved with :
driver.startActivity(new Activity("com.example", "ActivityName"));
Import by :
import io.appium.java_client.android.Activity;
With this method you can switch application, you must know the APP_PACKAGE and APP_ACTIVITY that you have, try this link or this link to learn this.
This is example the APP_PACKAGE and APP_ACTIVITY google chrome browser from play store :
driver.startActivity(new Activity("com.android.chrome", "com.google.android.apps.chrome.Main"));
You don't need to make a new initialize driver for the browser, just do it.
Your native apps start here
...
Switch to browser
//example chrome
driver.startActivity(new Activity("com.android.chrome", "com.google.android.apps.chrome.Main"));
....
//back to last activity your native app
driver.startActivity(new Activity("yourAPP_PACKAGE", "yourAPP_ACTIVITY"));
You can use Activity class to launch another application using AndroidDriver.startActivity() function like:
Activity activity = new Activity("activity.package", "activity.name");
activity.setStopApp(false);
((AndroidDriver<MobileElement>) driver).startActivity(activity);
An easier way would be just going for Launch command available via SeeTest Appium Extension like:
seetest.launch("activity.name", false, false);
I have a situation here that we have a webGL dependent application to automate. i have automated the whole application on my laptop, and this application is running fine on chrome on my laptop. but the issue is when i run this application from a seperate machine which is a selenium GRID node. It gives me a message that the application required Webgl and and it ask me to enable the webGL. i have tried different methods like selenium option and ignoring the chrome black list as well.
when i open the browser manually and open the application it runs find and i checked on url chrome://gpu. it shows that the gpu is enaled.
but when i invoke the selenium and run the test cases,. the browser initiates with WebGl as disabled
i found the solution to this. here is the code you can use to enable WebGL for chrome.
DesiredCapabilities capability = DesiredCapabilities.chrome();
ChromeOptions options = new ChromeOptions();
**options.addArguments("--ignore-gpu-blacklist");**
capability.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
capability.setCapability("chrome.binary", "C:\\Temp\\chromedriver.exe");
capability.setVersion("9999");
capability.setCapability(ChromeOptions.CAPABILITY, options);
return new RemoteWebDriver(HUB_URL,capability);
I have few selenium test cases; running fine on desktop website. My website is responsive; hence works fine on Mobile Browser also. How do I test my test cases on Mobile Browser ?
If your requirement is to test your site in Mobile view (As your site is responsive) then following code may help you -
FirefoxProfile ffprofile = new FirefoxProfile();
ffprofile.setPreference("general.useragent.override", "iPhone"); //this will change the user agent which will open mobile browser
WebDriver driver = new FirefoxDriver(ffprofile);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.manage().window().setSize(new Dimension(360,640)); //just to change the window size so that it will look like mobile
driver.get(siteURL);
You can use Appium to support the
Mobile web apps are web apps accessed using a mobile browser (Appium supports Safari on iOS and Chrome or the built-in ‘Browser’ app on Android).
Its design is based on the WebDriver API, so you’re free to use whatever test runner and test framework you already have. Keeping this in mind, your current Test engine should be insensitive to the application drivers and those are just plug&play “automation libraries” anyway.
Here is the Appium GitHub examples repo, which I like to use. You can find examples in:
RobotFramework
dotnet
java
node
perl
php
python
ruby