TestCafe headless mode - Safari - testing

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

Related

Cypress - how to run cypress automation in safari browser?

When i have checked the cypress latest version of 12.5.1 it is suggested to use the playwright-webkit where the safari browser is using the webkit engine it seems. here I need to simulate real time safari browser execution. Is there any way to do this?
I have tried to execute the playwright-webkit but unluckily it is not even open the URL and webkit is not working properly and if we switch to chrome or another browser it is working fine. but my request is to execute in safari the most.

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.

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.

What is the difference between testing on Safari vs Webkit?

I'm looking at writing some E2E tests using Playwright. I can see that the library allows tests to be run against Chromium, Firefox and Webkit. My understanding is that Webkit is the underlying engine of Safari, and Chromium is the base of Chrome (and other browsers).
When it comes to testing against Webkit/Chromium, how close is it to testing against the user facing browsers which use the underlying engines? I'd imagine that there would be some quirks which the user can run in to whilst using Safari and it wouldn't be caught when running the tests on Webkit.
Thanks
Stock browsers like Google Chrome, Apple Safari embed rendering engines (Chromium, WebKit) and add stuff on top of them. In particular, they add proprietary media codecs, inject browser extensions, etc. They also add surrounding interfaces such as bookmarks sync. But they reuse the underlying web platform implementation.
Chromium
Chromium is the open source web platform implementation used by Google Chrome, Opera, Microsoft Edge and other browsers. It implements web specs, renders content, works with network, etc. Playwright uses a stock Chromium build that can be automated with the Playwright API for e2e testing.
For Google Chrome things are simple: Chromium is a safe target to test, modulo proprietary media codecs and DRM. You can point Playwright against stock Chrome Canary or Edge Canary to use proprietary media codecs.
WebKit
WebKit is the open source web platform implementation used by Apple Safari and Epiphany. As of June 2020, Playwright provides a WebKit build that can be automated with the Playwright API for e2e testing. Playwright WebKit works across all platforms (macOS, Linux, Windows), in both headless and headful modes.
When WebKit runs on macOS, it is a safe target to test Safari. WebKit on Linux and Windows differs from Apple Safari in the following ways: it uses a non-macOS network stack, uses non-Core Animation to composite scene and produce image raster. This means that screenshots on Linux and Windows will not perfectly match screenshots from macOS. In terms of the web platform, the same WebKit code will layout the page and run JavaScript—it will match how WebKit works in Safari.
To conclude, we consider the browsers provided by Playwright to be the best of what you can get for e2e testing. Running WebKit on a Linux CI would use a different compositing pipeline than macOS, but it can be used for e2e testing of web applications in WebKit-powered browsers.
I've found there are some differences between webkit and Safari depending on which version of the two you're testing against.
I was testing Safari 16.0, and for my purposes Playwright 1v17 seemed to match very well. Upgrading to Safari 16.2 didn't seem to affect that.
But upgrading Playwright to 1v28 though seemed to change the behaviour around getting selection bounding boxes. It's seems more correct, but it's no longer consistent with Safari 16.2.
I'm assuming that WebKit is a bit ahead of Safari, and at some point Safari will catch up, and we'll see they are behaving the same again, but so far that's not happened. (Or maybe it has already, I'm a couple of versions behind at this point).
My solution has been to use both the latest version of Playwright for testing Chromium and Firefox, but use the older version for testing Safari. I am also testing webkit from Playwright 1v28 for interest right now, but I expect Safari will start showing that behaviour at some point.
(NB: Getting the bounding boxes of selections gets different results from each browser, so it's not too surprising that it's changing in WebKit right now. The change seems to be closer to Chrome's behaviour but still not the same).
In case it helps anyone, in my package.json devDependencies I have
"playwright1v17": "npm:playwright#~1.17.2",
"playwright1v28": "npm:playwright#~1.28.1",
and then in the test script I do
import { chromium, webkit, firefox } from 'playwright1v28';
import { webkit as safari16v1 } from 'playwright1v17';
That lets me test both versions of webkit and compare, as well as Chromium and Firefox.

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.