Image

What is testing?

Testing is the basic activity to tracing out the bugs and solving technical issues in the source code of a website and assessing the overall product functionality, performance, security, and compatibility with multiple platforms, browsers, and devices. It is part of the quality assurance and website development process.

What is automation testing?

Automation Testing is the testing technique to perform manual process by running some test cases using automation tool. Here you can automatically tracing out the bugs of a website and assessing the overall product functionality, performance, security, and compatibility with multiple platforms, browsers, and devices.

Why automation testing?

Automation Testing process will:

  • Reduce the cost and the testing time.
  • Automatically identify bugs testing on multiple OS, devices, and browsers.
  • Identify how a function is affecting other functions.
  • Can use the testing scripts multiple times.

What need for automation testing :

Steps for Automation Testing of any website

Here for automation testing with muliple browsers and OS compatibility we need to follow 4 steps.

Fetching the automation credentials from LambdaTest Automation Tab

1. Copy the automation credentials like “Username” and “Access Key” from Lambda Test Console.

2. Add those “Username” and “Access Key” on our “Environment Variable” via Control Panel.
Steps to add in Environment Variable:

  • Click on the Windows search bar and enter Environment variables.
  • Click on the “Edit the System environment variables”.
  • Now on System properties dialog box click on “Environment Variable”.
  • On the Environment Variable dialog box click on “New” under “System variable” section.
  • This will open the New System variable dialog.
  • For variable name, enter “LT_USERNAME”.
  • For variable value, enter the lambdatest username which we copied from lambda test console and click ok.
  • Follow last 2steps for adding “LT_ACCESS_KEY”.

Setting up our selenium automation project PyCharm

1. Install Python

  • Download the latest version of Python from here.
  • Then install it and also we can check the status of installation by run the command:
  • python --version

2. Install Pytest

  • Install pytest by running the following command:
  • pip install –U pytest

  • Then execute the following command to check the status of installation:
  • pytest --version

  • Sometimes it will ask for upgrade pip if you have previously then run the following command:
  • python -m pip install --upgrade pip

3. Install Pycharm

  • Open PyCharm Community Edition and Go to “Configure”.
  • Install it.

Adding the selenium library

1. Make pytest as a default runner tool

  • Open PyCharm Community Edition and Go to “Configure”.
  • Click on the settings.
  • Then click on “Tools” and then select the “Python Integrated tools”.
  • Then select “pytest” as a default test runner.

2. Create a Project

  • Click on Create new project.
  • Then make sure the “basic interpreter” should be selected as "pyton.exe" if not then browse it manually from there only.
  • Also check the Inherit global site-packages.

3. Add selenium libraries

  • Run the following command to add selenium libraries in our project:
  • pip install -U selenium

Note: Install appium library for mobile devices.

4. If we want to prform automation testing for mobile and ipad devices then we need to add appium package otherwise for desktop we need only selenium libraries.

  • For adding Appium library run the following command:
  • pip install Appium-Python-Client

5. Or we can directly add the library on our PyCharm console by the following steps

Creating a testing class and add the scenarios

A. Create a Selenium Remote Webdriver and add the browser where we want to run the Automation testing

1. Create conftest.py and also you can refer the code from here.

2. Here we need to add the browser information of which platform and browser we want to perform the automation testing.

For example, for Windows 10 platform and chrome browser the command is like

{ "platform": "Windows 10", "browserName": "chrome", "version": "83.0" }

For iphone and safari browser the command is like

{ "platform": "iOS", "deviceName": "iPhone 11", "version": "13.1", }

B. Creating a class and adding the test cases

Let see an example how the process flow while ordering a product from a website :

Create desktoptest.py and also you can refer the code from here.

1. Click the Buy Now button and navigate from the home page to the next page.

  • To identify the location of the button copy the “name” of the “Buy Now” button which we want to click.
  • Now we need to paste the name “gut-buy-nm-one” under our class to click the button.

driver.get('https://smarterguthealth.com/guthealth-beta/')
driver.find_element_by_name("gut-buy-nm-one").click()

2. Click the Buy Now button and navigate to the next page (In our case the 1 bottle and one-time purchase by default selected. If you want to select other bottle use script for the select item)

  • Copy the “name” of the “Buy Now” button.
  • Now we need to paste the name “ll_buy_btn” to click the button. Here we are using implicity_wait(20) to wait for 20sec for click the button.

driver.implicitly_wait(20)
driver.find_element_by_name("ll_buy_btn").click()

3. To fill the Shipping details

  • Copy the “name” of the first tab from where we want to type the test.
  • Similarly, we need add the id for fill the first tab
  • driver.find_element_by_id("firstName").send_keys("Test")

  • Similarly, add the all classes of each input field for testing

4. To click the “Go to Next Step” button and navigate to the billing page

  • Copy the id of the button to find out from where the navigation starts from one page to other page.
  • Add in the script to find the button by id and click it:
  • driver.find_element_by_id('create_prospect').click()

5. To fill the billing details and select order and click the submit button for navigating to oto1 page

  • To fill the tab copy the id of the credit card number tab
  • Paste the id as “creditcardNumber”
  • driver.find_element_by_id("creditcardNumber").send_keys("122xx4")

  • Similarly add the ids for other tabs, order bump and complete my order.

6. Click I want this deal button

  • Copy the id of the button we want to click
  • Add the id in the testing script
  • driver.find_element_by_id('upsell').click()

Similary, add the testing script for upsell2 page.

7. Finally to execute the test case we need to run the command like

pytest guthealth.py

guthealth.py is the file name where we added the test scenarios which we want to run for automation testing.

element

See in action : testing results for cross-browser / cross-platform compatibily

Automation testing for mobile devices

Automation testing for desktop devices

Manual testing for desktop devices

Receive latest marketing insights, data and inspiration

View Blogs ➞ Subscribe ➞

Start your Project Today