LambdaTest Community

Find answers, support, and inspiration from other users

Questions
LambdaTest Community
Answered

What are the top automated cross browser testing tools available to perform browser compatibility testing of a website?

Can anyone please suggest me some of the top automated cross browser testing tools available to perform browser compatibility testing of a website.

Up Vote Down Vote 0 Votes
Posted 4 months ago

Answers


Leveraging LambdaTest Platform For Performing Automation Testing in Parallel

While using Selenium WebDriver with Python for automation testing through your source code, you might land in a situation where you cannot verify the web application on the local infrastructure (or setup) that is currently available e.g. Your requirement is to test your web app with Firefox browser (version 64.0) installed on a Windows 10 machine. In such a process, you would require the required setup with the same version of Firefox installed on it. This approach is not only expensive but it is also non-scalable.

By leveraging cloud based, cross browser testing tools such as LambdaTest, you can verify your web app for cross browser compatibility across 2000+ different browsers, OS, resolutions, devices, etc. To get started, you have to create an account on LambdaTest. Once your account is activated, you need to make note of the username & access-key which is located at your LambdaTest Profile.

You have to generate the necessary capabilities i.e. mandatory (and optional) requirements that are necessary for executing the test code e.g. Capabilities could be (platform OS – Windows 10, BrowserName – Firefox, BrowserVersion 64.0, Firefox Driver version – v0.23.0. The Desired capabilities can be generated by visiting LambdaTest Capabilities Generator. You have to make sure that the language for development is selected as ‘Python’.

capabilities = { "build" : "your build name",
        "name" : "your test name",
        "platform" : "Windows 10",
        "browserName" : "Firefox",
        "version" : "64.0",
        "selenium_version" : "3.13.0",
        "visual" : true,
        "firefox.driver" : v0.23.0}

In order to get the maximum throughput from Selenium WebDriver with Python for automation testing through the LambdaTest platform, it is necessary that you choose a plan which provides the feature of ‘Parallel Testing’. More details about the billing plans are available at their pricing page.

Now that our setup is ready, we perform a simple test for performing parallel testing in Selenium WeDriver with Python for automation testing on LambaTest cloud platform. Details about the tests are below.

Test 1: 1. Invoke Chrome browser (version 67.0) on Windows 10 2. Search for ‘lambatest’ on Google 3. Once the page is rendered, close the browser and clear the resources allocated during the start of the test. Test 2: 1. Invoke Firefox browser (version 64.0) on Windows 10 2. Search for ‘lambatest’ on Google 3. Once the page is rendered, close the browser and clear the resources allocated during the start of the test. Implementation for Test 1

LambdaTest Selenium automation sample example
Configuration
----------
username: Username can be found at automation dashboard
accessToken:  AccessToken can be generated from automation dashboard or profile section
 
Result
-------
Execute Python Automation Tests on LambdaTest Distributed Selenium Grid
"""
import unittest
import time
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import urllib3
class LTAutomate(unittest.TestCase):
 
    """
    Setup remote driver
    Params
    ----------
    platform : Supported platform - (Windows 10, Windows 8.1, Windows 8, Windows 7,  macOS High Sierra, macOS Sierra, OS X El Capitan, OS X Yosemite, OS X Mavericks)
    browserName : Supported platform - (chrome, firefox, Internet Explorer, MicrosoftEdge)
    version :  Supported list of version can be found at https://www.lambdatest.com/capabilities-generator/
 
    Result
    -------
    """
    def setUp(self):
        # username: Username can be found at automation dashboard
        username="<user-name>" 
        # accessToken:  AccessToken can be generated from automation dashboard or profile section
        accessToken="<access-token>"
        # gridUrl: gridUrl can be found at automation dashboard
        gridUrl = "hub.lambdatest.com/wd/hub"
         
        desired_cap = {
            'platform' : "win10",
            'browserName' : "chrome",
            'version' :  "67.0",
            "resolution": "1024x768",
            "name": "LambdaTest python google search test ",
            "build": "LambdaTest python google search build",
            "network": True,
            "video": True,
            "visual": True,
            "console": True,
        }
 
        # URL: https://{username}:{accessToken}@hub.lambdatest.com/wd/hub
        url = "https://"+username+":"+accessToken+"@"+gridUrl
         
        print("Initiating remote driver on platform: "+desired_cap["platform"]+" browser: "+desired_cap["browserName"]+" version: "+desired_cap["version"])
        self.driver = webdriver.Remote(
            desired_capabilities=desired_cap,
            command_executor= url
        )
 
    """
    Setup remote driver
    Params
    ----------
    Execute test:  navigate google.com search LambdaTest
    Result
    -------
    print title
    """
    def test_search_in_google(self):
        driver = self.driver
        print("Driver initiated successfully.  Navigate url")
        driver.get("https://www.google.com/ncr")
 
        print("Searching lambdatest on google.com ")
        time.sleep(8)
        elem = driver.find_element_by_name("q")
        elem.send_keys("lambdatest.com")
        elem.submit()
 
        print("Printing title of current page :"+driver.title)
        driver.execute_script("lambda-status=passed")
        print("Requesting to mark test : pass")
 
    """
    Quit selenium driver
    """
    def tearDown(self):
        self.driver.quit()
 
if __name__ == "__main__":
    unittest.main()

Implementation for Test 2

LambdaTest Selenium automation sample example
Configuration
----------
username: Username can be found at automation dashboard
accessToken:  AccessToken can be generated from automation dashboard or profile section
 
Result
-------
Execute Python Automation Tests on LambdaTest Distributed Selenium Grid
"""
import unittest
import time
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import urllib3
class LTAutomate(unittest.TestCase):
 
    """
    Setup remote driver
    Params
    ----------
    platform : Supported platform - (Windows 10, Windows 8.1, Windows 8, Windows 7,  macOS High Sierra, macOS Sierra, OS X El Capitan, OS X Yosemite, OS X Mavericks)
    browserName : Supported platform - (chrome, firefox, Internet Explorer, MicrosoftEdge)
    version :  Supported list of version can be found at https://www.lambdatest.com/capabilities-generator/
 
    Result
    -------
    """
    def setUp(self):
        # username: Username can be found at automation dashboard
        username="<user-name>" 
        # accessToken:  AccessToken can be generated from automation dashboard or profile section
        accessToken="<access-token>"
        # gridUrl: gridUrl can be found at automation dashboard
        gridUrl = "hub.lambdatest.com/wd/hub"
         
        desired_cap = {
            'platform' : "win10",
            'browserName' : "firefox",
            'version' :  "64.0",
            "resolution": "1024x768",
            "name": "Parallel Test - LambdaTest python google search test on Firefox",
            "build": "Parallel Test - LambdaTest python google search build on Firefox",
            "network": True,
            "video": True,
            "visual": True,
            "console": True,
        }
 
        # URL: https://{username}:{accessToken}@hub.lambdatest.com/wd/hub
        url = "https://"+username+":"+accessToken+"@"+gridUrl
         
        print("Initiating remote driver on platform: "+desired_cap["platform"]+" browser: "+desired_cap["browserName"]+" version: "+desired_cap["version"])
        self.driver = webdriver.Remote(
            desired_capabilities=desired_cap,
            command_executor= url
        )
 
    """
    Setup remote driver
    Params
    ----------
    Execute test:  navigate google.com search LambdaTest
    Result
    -------
    print title
    """
    def test_search_in_google(self):
        driver = self.driver
        print("Driver initiated successfully.  Navigate url")
        driver.get("https://www.google.com/ncr")
 
        print("Searching lambdatest on google.com ")
        time.sleep(8)
        elem = driver.find_element_by_name("q")
        elem.send_keys("lambdatest.com")
        elem.submit()
 
        print("Printing title of current page :"+driver.title)
        driver.execute_script("lambda-status=passed")
        print("Requesting to mark test : pass")
 
    """
    Quit selenium driver
    """
    def tearDown(self):
        self.driver.quit()
 
if __name__ == "__main__":
    unittest.main()

Let us do a code-walk through of Test 1 (Note – Apart from the type of browser being invoked, rest of the functionalities are same for Test 2 as well).

All the necessary modules are imported in the beginning (unittest, selenium, etc.)

You need to set the necessary capabilities required for test execution. We recommend that you make use of LambdaTest Capability Generator (which was discussed earlier) to generate the ‘desired capabilities’.

desired_cap = {'platform' : "win10",
            'browserName' : "firefox",
            'version' :  "64.0",
            "resolution": "1024x768",
            "name": "Parallel Test - LambdaTest python google search test on Firefox",
            "build": "Parallel Test - LambdaTest python google search build on Firefox",
            "network": True,
            "video": True,
            "visual": True,
            "console": True,}

In the setUp() method, you should enter your user-name & access-token for accessing the LambdaTest platform to go ahead with Selenium Webdriver with Python for automation testing. If these credentials are incorrect, you might not be able to execute the code. Since the execution is performed on the cloud, we make use of ‘Remote WebDriver API’ instead of ‘Local WebDriver API’. The inputs to the ‘Remote WebDriver API’ are ‘desired capabilities’ and ‘command execution URL (created using concatenation of [user-name + access-token + grid URL].

You can now execute parallel testing in Selenium WebDriver with Python for automation testing. Notice the two tests on different terminals by using the ‘python’ command.

In order to check the status of the tests, logs, MetaData, etc.; you need to check the ‘Automation’ tab on Lambatest i.e. https://automation.lambdatest.com

As shown in the automation snapshot below, there is a field which mentions how many tests are executing/running. In our case, we executed parallel testing in Selenium WebDriver with Python for automation testing using 2 tests in Parallel (i.e. concurrent sessions). Hence, when you invoke the tests, they are executed in parallel. In this manner, you can speed up your overall test case execution in a significant manner.

Up Vote Down Vote 0 Votes
Posted 4 months ago