Database Verification Using Selenium Webdriver

broken image


Main usage of database In selenium WebDriver Is getting records from table and use them In your selenium test as per your requirement. Simple example Is you can use that data to perform data driven testing or you can verify data In tables which you have Inserted through web application
forms. Now supposing you wants to

Alternativly you could check the database with a query, depending on the data-store you can use a non-Selenium library to retrieve data from it. For accessing databases with SQL and Java research this documentation. (Note use database checks with caution. Try to test behaviour not implementation.

update data directly In
  1. Selenium is a browser automation tool. If you are using Selenium to test your database, you are doing it wrong! Does this database testing have anything to do with opening a web application in a browser? If yes then selenium/WebDriver could be used.
  2. Database Testing using Selenium: Step by Step Guide Selenium Webdriver is limited to Testing your applications using Browser. To use Selenium Webdriver for Database Verification you need to use the JDBC ('Java Database Connectivity'). JDBC (Java Database Connectivity) is a SQL level API that allows you to execute SQL statements.
  3. How to store a webtable in arraylist then verify the data in selenium webdriver. Ask Question Asked 3 years, 6 months ago. How to select multiple rows at different place in a table using Selenium Webdriver. Selenium WebDriver generates StaleElementReferenceExeption on getText on table elements. Database Administrators; Drupal.
  4. Here, in my blog, I will be discussing database testing using selenium webdriver. Selenium webdriver will simply interact with my browser and do the expected tasks which I have scripted in test script using java. Let's Discuss database testing in more details. What is Database Testing? Database Testing is the verification of retrieved values.
MySql data table
Database Verification Using Selenium Webdriver
and then you wants to verify same thing In UI then you can do It very easily.
Note : Please read all previous posts on database testing. Links are listed on THIS PAGE.
Updating specific data cell In MySql database table
Database Verification Using Selenium Webdriver
In my previous post, We learnt how to select specific record using PreparedStatement Interface. Now we will use executeUpdate() method to update specific record which Is selected by where clause.
Selenium webdriver java
Bellow given example will set name = 'Danial' where id = 5 In user table. Main thing to learn In this example Is how to write query string and set Its parameters to update specific record. Execute bellow given example In eclipse.
DOWNLOAD UpdateRecordInDB.zip folder. You will get UpdateRecordInDB.java test script file In zip folder when extract It. Import It In your eclipse and then execute
At the end of execution, It will show you databse table records In console as shown In above Image. You can see In Image that records with id = 5 Is updated with name = 'Danial'. Now If you have website UI then you can check same thing there using selenium webdriver.

<< PREVIOUS || NEXT >>

QA folks need to do Regression Testing as part of their Job.

Since doing Regression on daily/weekly basis is cumbersome, we automate the functional flows of our application and these are called FTs (Functional Tests).

Selenium Webdriver Firefox

Apart from executing the FTs, we do manual testing mostly to validate the alignment, font size, colour etc.

Since, manually verifying the colour of all controls/elements is a tedious and time-consuming job, we should automate it also.

How?

We can automate it by using Selenium Webdriver itself.

For example, I am taking Java as a language of choice with Selenium WebDriver.

Now, let's see how to verify/assert colour in Selenium WebDriver.

Here, we are verifying the colour of the label 'Forgot Password?' on Naukri Recruiter Login Page. For reference, see following screen shot:

Steps:

First of all, we have to get the value of colour using getCssValue method provided by Selenium Webdriver.

Darcy Ali Liebert won the Canadian Screen award for Best Actress in a Featured Supporting Role in a Dramatic Series for her portrayal of Betty McRae in Reelz/Global TV's original hit series, 'Bomb Girls' and won a Leo Award for the same character. 'Mech-X4' (DisneyXD), 'Lost Girl' (Syfy), 'Ten Days in. Ali liebert mech x4 x1. Ali Liebert, Actress: Bomb Girls. Ali Liebert is a Canadian Screen Award winner ('Best Actress in a Featured Supporting Role in a Dramatic Series') for her portrayal of Betty Mcrae in Reelz/Global TV's original hit series, Bomb Girls. She also won a Leo Award for the same character. In 2013, Whistler Film Festival, Elle Canada & Variety named her 'Rising Star of the Festival'. Kim Grey (Ali Liebert) is a recurring villainess from Disney XD's series, Mech-X4. Ali Liebert portrays Principal Grey in Mech-X4.

We can do it by using the below code:

String color = driver.findElement(By.xpath('//div[contains(@class, ‘logo-subtext')]')).getCssValue('color');

In the above code, CSS attribute ‘color' is stored in a String variable ‘color'.

The above code will return value in RGB format such as 'rgba(36, 93, 193, 1)'.

Download Virtua Tennis 3 ROM for Playstation Portable(PSP ISOs) and Play Virtua Tennis 3 Video Game on your PC, Mac, Android or iOS device! Free Download Game Virtua Tennis 3 (USA) ISO PSP region USA size 308.2MB, PPSSPP. Download the Game from the download link, provided in the page. Screenshots: Game Description - Virtua Tennis 3: Virtua Tennis 3 is a popular PlayStation PSP Video Game and now you can play this game on android using PPSSPP android emulator. Virtua Tennis 3 (Sega Professional Tennis: Power Smash 3 in Japan) is the second arcade game sequel to. Download Virtua Tennis 3 PSP PPSSPP Virtua Tennis 3 (Sega Professional Tennis: Power Smash 3 in Japan) is the second arcade game sequel to Sega's tennis game franchise, Virtua Tennis. The arcade version of Virtua Tennis 3 is powered by the PC-based Sega Lindbergh arcade system board. CoolROM.com's game information and ROM (ISO) download page for Virtua Tennis 3 (Europe) (Sony Playstation Portable).

Database Validation In Selenium Webdriver

Now we will convert it into hexadecimal code using Java as shown below:

String[] hexValue = color.replace('rgba(', '').replace(')', '').split(',');

hexValue[0] = hexValue[0].trim();

Webdriver
and then you wants to verify same thing In UI then you can do It very easily.
Note : Please read all previous posts on database testing. Links are listed on THIS PAGE.
Updating specific data cell In MySql database table
In my previous post, We learnt how to select specific record using PreparedStatement Interface. Now we will use executeUpdate() method to update specific record which Is selected by where clause.
Bellow given example will set name = 'Danial' where id = 5 In user table. Main thing to learn In this example Is how to write query string and set Its parameters to update specific record. Execute bellow given example In eclipse.
DOWNLOAD UpdateRecordInDB.zip folder. You will get UpdateRecordInDB.java test script file In zip folder when extract It. Import It In your eclipse and then execute
At the end of execution, It will show you databse table records In console as shown In above Image. You can see In Image that records with id = 5 Is updated with name = 'Danial'. Now If you have website UI then you can check same thing there using selenium webdriver.

<< PREVIOUS || NEXT >>

QA folks need to do Regression Testing as part of their Job.

Since doing Regression on daily/weekly basis is cumbersome, we automate the functional flows of our application and these are called FTs (Functional Tests).

Selenium Webdriver Firefox

Apart from executing the FTs, we do manual testing mostly to validate the alignment, font size, colour etc.

Since, manually verifying the colour of all controls/elements is a tedious and time-consuming job, we should automate it also.

How?

We can automate it by using Selenium Webdriver itself.

For example, I am taking Java as a language of choice with Selenium WebDriver.

Now, let's see how to verify/assert colour in Selenium WebDriver.

Here, we are verifying the colour of the label 'Forgot Password?' on Naukri Recruiter Login Page. For reference, see following screen shot:

Steps:

First of all, we have to get the value of colour using getCssValue method provided by Selenium Webdriver.

Darcy Ali Liebert won the Canadian Screen award for Best Actress in a Featured Supporting Role in a Dramatic Series for her portrayal of Betty McRae in Reelz/Global TV's original hit series, 'Bomb Girls' and won a Leo Award for the same character. 'Mech-X4' (DisneyXD), 'Lost Girl' (Syfy), 'Ten Days in. Ali liebert mech x4 x1. Ali Liebert, Actress: Bomb Girls. Ali Liebert is a Canadian Screen Award winner ('Best Actress in a Featured Supporting Role in a Dramatic Series') for her portrayal of Betty Mcrae in Reelz/Global TV's original hit series, Bomb Girls. She also won a Leo Award for the same character. In 2013, Whistler Film Festival, Elle Canada & Variety named her 'Rising Star of the Festival'. Kim Grey (Ali Liebert) is a recurring villainess from Disney XD's series, Mech-X4. Ali Liebert portrays Principal Grey in Mech-X4.

We can do it by using the below code:

String color = driver.findElement(By.xpath('//div[contains(@class, ‘logo-subtext')]')).getCssValue('color');

In the above code, CSS attribute ‘color' is stored in a String variable ‘color'.

The above code will return value in RGB format such as 'rgba(36, 93, 193, 1)'.

Download Virtua Tennis 3 ROM for Playstation Portable(PSP ISOs) and Play Virtua Tennis 3 Video Game on your PC, Mac, Android or iOS device! Free Download Game Virtua Tennis 3 (USA) ISO PSP region USA size 308.2MB, PPSSPP. Download the Game from the download link, provided in the page. Screenshots: Game Description - Virtua Tennis 3: Virtua Tennis 3 is a popular PlayStation PSP Video Game and now you can play this game on android using PPSSPP android emulator. Virtua Tennis 3 (Sega Professional Tennis: Power Smash 3 in Japan) is the second arcade game sequel to. Download Virtua Tennis 3 PSP PPSSPP Virtua Tennis 3 (Sega Professional Tennis: Power Smash 3 in Japan) is the second arcade game sequel to Sega's tennis game franchise, Virtua Tennis. The arcade version of Virtua Tennis 3 is powered by the PC-based Sega Lindbergh arcade system board. CoolROM.com's game information and ROM (ISO) download page for Virtua Tennis 3 (Europe) (Sony Playstation Portable).

Database Validation In Selenium Webdriver

Now we will convert it into hexadecimal code using Java as shown below:

String[] hexValue = color.replace('rgba(', '').replace(')', '').split(',');

hexValue[0] = hexValue[0].trim();

int hexValue1 = Integer.parseInt(hexValue[0]);

hexValue[1] = hexValue[1].trim(); How to print to pdf windows 7.

int hexValue2 = Integer.parseInt(hexValue[1]);

hexValue[2] = hexValue[2].trim();

int hexValue3 = Integer.parseInt(hexValue[2]);

String actualColor = String.format('#%02x%02x%02x', hexValue1, hexValue2, hexValue3);

It is done!!

You will get the value of colour in Hexadecimal code after executing the above code.

We can add an Assert statement to verify that the colour is matching with the expected colour.

Assert.assertTrue(actualColor.equals('#0045d0'));

//Expected value is taken from the above screen shot

After performing all the above steps, your whole method looks like below:

Usage:

  • You can integrate this colour-verification code in your existing test cases. So there is no need to maintain the separate test cases for colour verification of Elements
  • You can verify the colour changing scenarios while hovering the mouse on Elements
  • You can verify the colours of the messages (like error message, warning message, some information, etc.)

I hope you found this blog helpful !!

Related Posts

Posted in Automation, Automation Testing, Quality Assurance




broken image