Posts

Showing posts from 2019

WebDriver Exploration Part-3(WebDriver Waits)

You may come across scenario's where you see elements on pages are loaded after some delay or after some specific event. In such a case, our scripts can fail and complain it cannot find the element. To tackle such scenario's we can have our script developed in such a way that it will wait for some predefined time before interacting with such type of elements We will stick to our earlier example of clicking Gmail link on google home page, here we assume Gmail link appears after some delay on the home page, below are the ways we can tackle this Sleeping till things appear on the page 😴 Yes. Sleeping till things get to normal. Assuming that Gmail link appears within 10 seconds after the page is loaded, we can sleep for 10 seconds before interacting with it, check below [ TestMethod ]          public   void  Verify_Wait_Sleep()         {         ...

Test HTML-WebDriver Wait

Dynamically add Textbox, Radio, Button in html Form using JavaScript Dynamically add element in form. Select the element and hit Add to add it in form. Button Textbox Radio  

WebDriver Exploration Part-2(Locating WebElements)

In this lecture, we will learn how we can locate elements and perform an operation on them. WebElement represents the HTML element with whom we interact during testing. We will now look at how we can find elements and store them in IWebElement Interface Inspecting Element in Chrome browser Open Google home page and right-click on the element with you want to inspect and choose inspect from the popup menu and you can see all the HTML attributes for the element Now we know how can one inspect an element, we will start with locating element and then we will create sample script to interact with an element Locating by ID We will open the google home page and inspect the image above the search text box and you will see that the image is in Div tag with ID as "hplogo". We will create a script to find the div element and then click on the element which will open the search page as per the logo image [ TestMethod ]          public   ...

WebDriver Exploration Part-1(Setting the stage for WebDriver)

In this lecture, we will set up and start exploring  the Webdriver API Let's commence Setting the stage  I have created a new Unit test project called 'WebDriverCourse', which we will be used for WebDriver exploration lectures Right-click on the project -->Manage Nuget packages Click on Browse and search for Selenium.WebDriver and install same. Now you can see the project has reference to WebDriver DLLs under the reference section of the project. Below is the default unitTest.cs file which is autogenerated during project creation namespace   WebDriverCourse {      [ TestClass ]      public   class   UnitTest1      {          [ TestMethod ]          public   void   TestMethod1 ()          {          }  ...

Selenium WebDriver and Automation Framework Introduction

Image
Selenium WebDriver API helps us to automate browser-based applications So why one should go for selenium web driver to automate their web application testing? Selenium is Free Support multiple languages like C#, java etc Huge community easy to use Well that's just good part, can you tell me limitations if any Only works for browser Element identification can be a pain for some applications Sometimes some things will not work the way it is and you need to hack a bit (This is very rare and completely depends on web application one is testing) To know more about selenium web driver refer to the official documentation Automation Framework When we start automating the web application and start adding more and more scripts, we start to realize that we are repeating a lot of stuff and not reusing code, as our motive is to just automate the script. Sooner we fell that all the heavy lifting code which we have in our test cases should be moved to some common compo...

Specflow -Part6(Specflow Hooks)

Image
We may come across a scenario where we need to execute code after/before a particular event like given below We want to create some folder where we can store screenshots/ logfile before starting the test We may want to log details of the scenario in a log file after executing each step  We want to know after each step if that step was successful and if not we want to take a screenshot as an evidence We want to clean up the database before/after each scenario/feature  We  may want to open/close browser for every scenario Hooks help us to execute logic when a certain event occurs, let's check how I will start with creating a new project called SeleniumHooks and added folders where we can keep our feature, feature definitions and hooks file We will add a feature file and implement the steps Feature : SpecFlowFeature1 In order to avoid silly mistakes As a math idiot I want to be told th...

Specflow -Part5(Specflow Sharing Data Between Steps)

While automating applications you may come across scenarios where you may need to share data between steps, we will talk about how one can do so in this lecture Let's say you are automating google search functionality and scenario is user types search string on the google search page and hits search and this takes him to the google result page where he asserts if the results match the search string. You can have a single step definition file for all these steps or you can have a separate one for each page. Ideally, you should have a separate step definition file for each page. We can share the data between steps using below ways Instance variables (Steps are in same file) Context Instance variables We will create a feature file for the above example and then we can talk over it Feature : SpecFlowFeature4 To demo how one can share data between steps Scenario : Verify user can share data bet...

Specflow -Part4(Specflow Scenario Outline and Feature Background )

In the previous lecture, we talked about how we can pass multiple data to step using tables, suppose we want to run the same scenario for a different set of data, For example, you want to test the login functionality of an application, where you test login with Administrator, Project Manager, Product Owner etc Here the steps of scenario will remain the same only the login credentials will change according to the user. We can have the same scenario run multiple times for each user you want to test with the help of scenario outline, check below Feature file Feature : SpecFlowFeature3 In order to test the login functionality for multiple users, we will demo using scneario outline Scenario Outline : Verify login for different set of users Given  User trys to login into application using  <Username>  and  ...