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
Related
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
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 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);
Is there a way to record / generate a video file of the browser session for selenium webdriver with the following setup?
Environment / Test Setup:
e2e web tests (written in any language)
selenium standalone server with chrome
Since, there is no direct support from selenium, you may use third party tool like Monte Media Library. See the link:
How to perform screen recording with the help of selenium?
Hope, this will help you.
I have successfully tested applications in FireFox using Selenium WebDriver, but one of our applications runs in a custom browser made using QTWebKit. Is it possible to use WebDriver to automate testing in a custom browser like this?
There is a webdriver for QtWebkit here: https://github.com/cisco-open-source/qtwebdriver
It also can automate qtwidget and QML aplications.
You should be able to use it to automate you custom browser, provided you preserved the QtWebkit APIs.
If QTWebKit has released a WebDriver executable for the browser, then yes.
Otherwise - no.