Mobile browser automation - selenium

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.

Related

TestCafe headless mode - Safari

I'm evaluating TestCafe as a potential UI testing tool for our team. The target browser is Safari. Is that correct that headless tests cannot be run with Safari?
There is not a headless mode for Safari. It isn't unique to TestCafe; you won't be able to run in headless mode in Safari with any testing framework.
Source: https://discussions.apple.com/thread/251837694

Unable to test against Safari using v1.18.0

I just updated to TestCafe v1.18.0 and I followed the upgrade guide. I am able to run tests against Chrome and Firefox, as the system correctly prompted me if I wanted to let TestCafe control these, but this is not happening for Safari, so I am unable to test against it. I don't see any way to manually add an entry in the Automation tab either.
Automation Tab entry for TestCafe Browser Tools
Edit: I managed to add it using the remote option for TestCafe and pasting the URL into Safari, but even after that, npx testcafe safari is unable to launch Safari. I'm using an M1 Mac and macOS Monterey 12.0.1
TestCafe 1.18.0 does have the Safari-related issue. It has already been fixed. Please update TestCafe to v1.18.1.

Does WebDriver Manager also working for Appium?

Is there any Appium manager like the webdriver manager for using? since the appium is implements the Webdriver so..is it there?
Or maybe there is option to use it for Appium drivers too? (Android driver - IOS driver)
Thank you
you don't need to download a "driver" for appium. The drivers comes with the appium package for hybrid and native app testing.
so once you initialize the driver capabilities , appium will automatically install the reuired driver on the device and allows appium server to communicate with the device through xcuitest or uiautomator apis

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 automate Firefox Mobile with 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.