How to automate Firefox Mobile with Selenium? - selenium

I need to run Selenium tests in Firefox Mobile. Could anybody describe an easy way to do this? My investigation shows that:
Firefox Mobile is not supported in Appium (one, two).
Firefox Desktop has built-in Responsive Design Mode like shown on the picture:
It seems that Geckodriver does not support Firefox mobile. Compared to Chromedriver Geckodriver has no mobile-specific code.
There is (or there was) some way to open mobile emulation using Firefox prefs. It works by switching Firefox from CONTENT to CHROME context using Marionette API calls and then pressing keyboard shortcut with Selenium.
Did not manage to succeed with any of these solutions. Any idea how to automate Firefox Mobile?

You can try to emulate it on the FireFox Desktop app by using Geckodriver and changing User Agent and device size (width and height). Here is an example in Python 3:
user_agent = "Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16"
profile = webdriver.FirefoxProfile()
profile.set_preference("general.useragent.override", user_agent)
driver = webdriver.Firefox(profile)
driver.set_window_size(360,640)

binary = FirefoxBinary('geckodriver.exe')
capabilities = {
'browserName': 'firefox',
'firefoxOptions': {
'mobileEmulation': {
'deviceName': 'iPhone X'
}
}
}
browser = webdriver.Firefox(firefox_binary=binary, desired_capabilities=capabilities)
This should work. Havent tested it so try it and let me know.

Related

Mobile browser automation

can we automate mobile browsers without using any emulators or real devices and directly using a web browser?
I know we can use appium to test mobile browsers but for that, we need to have either emulator or real device
I have a web test framework and I want to use the same for mobile browser testing
Yes, you can do it with web browser, using selenium, only you should do to set the dimension size of your mobile:
for example: driver.manage().window().setSize(new Dimension(800, 600));
Potentially yes. However, with a lot of limitations and extra efforts.
You may use the Chrome Dev Tools Mobile Emulation for that:
See this article for details
Selenium allows for remote automation and is supported by both chrome and firefox browsers. Steps for chrome automation in android are:
Enable usb debugging in phone and connect it to pc or laptop
Install python and selenium and android sdk in pc or laptop
adb start-server
adb shell su -c chmod 777 /data/local
./chromedriver
Above commands will display a port number. Just note it down as it will be required further.
Then start automation. Below is small example:
from selenium import webdriver
options = webdriver.ChromeOptions()
options.add_experimental_option('androidPackage', 'com.android.chrome')
driver = webdriver.Chrome('./chromedriver', options=options)
driver.get('https://google.com')
driver.quit()
OR
from selenium import webdriver
capabilities = {
'chromeOptions': {
'androidPackage': 'com.android.chrome',
}
}
driver = webdriver.Remote('http://localhost:9515', capabilities) # Specify your port number value
driver.get('http://google.com')
driver.quit()
Both google chrome stable and beta apps available from play store are supported.
Same can be done with firefox and gecko driver. Just change Chrome in above code worh Firefox and chromedriver with geckodriver.
Hope it helped you.

Automate Opera Mini Tests via Appium/Selenium

I have researched how to test mobile web apps via Appium (to use the mobile sdk)
The achieve automation of opera browser tests, one can use selenium / appium with the opera chrome or presto drivers (imported libraries)
However there is no documentation with regards to running automation on opera mini applications.
Does anyone know if this is possible? Has anyone successfully used Apium to test Opera Mini?
Though it is not supported out of the box by Appium (CHROME, CHROMIUM, SAFARI are listed), you can use operachromiumdriver:
desired_caps['chromedriverExecutable'] = '/absolute/path/to/operadriver'
desired_caps['app'] = os.path.abspath('opera-browser.apk')
desired_caps['appPackage'] = 'com.opera.browser'
desired_caps['androidDeviceSocket'] = desired_caps['appPackage'] + '.devtools'
So I was able to use the opera driver to automate tests on the opera browser on android, however, it was unable to provide the functionality needed to automate testing on the opera mini browser on android.

How to inspect a <canvas> in Safari?

I have a need to inspect what is being drawn in a <canvas>, as in this question. And I know how to use the Chrome dev tools canvas inspector, and the Firefox Canvas Debugger.
Are there any similar tools for the Safari web browser?
For the sake of clarity, let's assume desktop Safari v9.1.1 running in OSX 10.10.

Appium codeception iOS simulator error: could not find any webviews yet refreshing/retrying

When I try to launch safari on iPad simulator and do $I->amOnPage("http://www.amazon.com"). Safari browser is launched but is stuck at http://127.0.0.1:4723/welcome. I see in appium logs this warning "could not find any webviews yet refreshing/retrying" and then nothing happens.
I use Appium 1.4.8, OS X 10.10 Yosemite, codeception 2.1.2, XCode 6.4. I have no idea what I am doing wrong. I looked up online and some said I should be running ios_webkit_proxy_launcher. I tried running that on 27753 with -c and simulator UDID -d options and retried my test. Still no change. ios proxy starts up but has no logs whatsoever. These are the desired capabilities I am using :
modules:
enabled:
- WebDriver
config:
WebDriver:
url: 'http://www.amazon.com'
connection_timeout: 500
request_timeout: 500
browser: 'safari'
host: 127.0.0.1
port: 4723
capabilities:
browserName: 'safari'
platformVersion: "8.4"
platformName: "iOS"
deviceName: 'iPad Retina'
connection_timeout: 500
request_timeout: 500
Any ideas? Thanks.
However I can get things to work fine with PHPUnit! Dont know whats going on with codeception.
I also faced issue while opening webview in safari browser. I was working with iPhone device. But below pre-conditions should be same for simulator.
machine should have:
Appium installed.
libplist 1.10 installed.
libusbmuxd 1.0.8 installed.
libimobiledevice 1.1.5 installed.
If you are running on device turn on (settings go to developer then
UIautomator)UI automator and safari go to advanced turn on web
inspector.
open terminal run following command:-
ios_webkit_debug_proxy
Hit enter
open new window on terminal hit following command:-
ios_webkit_debug_proxy –c:27753 –d
Don’t change port number.
Device(in your case , simulator) should be connected to machine.
Maybe you need to enable Web Inspector of Safari on your device.
Settings > Safari > Advanced > Web Inspector = ON

Change Default Browser Programmatically Mac OSX

How would you change the default browser programmatically on Mac OSX.
For example from safari to chrome, or chrome to firefox?
Thanks
You should use
LSSetDefaultHandlerForURLScheme(
CFStringRef inURLScheme, CFStringRef inHandlerBundleID)
See also Launch Service Reference Docs.
Use #"http" for the inURLScheme, and figure out the bundle identifiers of Firefox, Chrome etc. to use.
You can also check which are installed using
LSCopyAllHandlersForURLScheme(CFStringRef inURLScheme)