Automation Using Selenium Webdriver

Wednesday, 23 July 2025

 

✅ What is Playwright?

Playwright is an open-source automation library for testing web applications across multiple browsers. It supports ChromiumFirefox, and WebKit and works with JavaScript, TypeScript, Python, C#, and Java.


๐Ÿ”น Key Features

  • Cross-browser testing (Chrome, Firefox, Safari)

  • Auto-wait mechanism for elements

  • Built-in support for headless/headful mode

  • Parallel test execution

  • Page Object Model (POM) support

  • CI/CD integration


    ๐Ÿ› ️ Step-by-Step Guide

    Step 1: Install Node.js and Playwright

    npm init -y
    npm install -D @playwright/test
    npx playwright install

    Step 2: Basic Folder Structure

    /playwright-project
      ├── tests/
      │   └── example.spec.js
      ├── playwright.config.js
      └── package.json

    Step 3: Sample Test Case

    // tests/example.spec.js
    const { test, expect } = require('@playwright/test');
    
    test('Home page title test', async ({ page }) => {
      await page.goto('https://example.com');
      await expect(page).toHaveTitle('Example Domain');
    });

    Step 4: Run Your Test

    npx playwright test

    ๐Ÿ” Understanding Core Concepts

    1. Browser Context

    Each test runs in a new browser context, isolated from others. Think of it like a new browser window.

    2. Selectors

    Playwright supports powerful selectors:

    • CSS: page.locator('h1')

    • Text: page.getByText('Submit')

    • XPath: page.locator("//button[text()='Submit']")

    3. Assertions

    await expect(page).toHaveTitle(/Example/);
    await expect(page.locator('h1')).toHaveText('Example Domain');

    4. Fixtures

    Use built-in test fixtures to manage browser/page lifecycle.

    5. Page Object Model (POM)

    Organize your code with POM:

    class LoginPage {
      constructor(page) {
        this.page = page;
        this.username = page.locator('#username');
        this.password = page.locator('#password');
        this.loginBtn = page.locator('button[type=submit]');
      }
    
      async login(user, pass) {
        await this.username.fill(user);
        await this.password.fill(pass);
        await this.loginBtn.click();
      }
    }

    ๐Ÿš€ Advanced Tips

    • Use tracing to debug failed tests

    • Run in parallel using --workers

    • Integrate with JenkinsGitHub Actions, or Azure DevOps


    ๐Ÿ“ฆ Integrating with CI/CD (Azure DevOps)

    • Create a YAML pipeline

    • Add Playwright install and test steps

    - script: |
        npm ci
        npx playwright install --with-deps
        npx playwright test
      displayName: 'Run Playwright tests'

    ๐Ÿงช Real-Time Use Cases

    • Login test automation

    • E-commerce cart validation

    • Checkout flow automation

    • API + UI integration test

Wednesday, 31 May 2017

Agile Testing Interview Questions 1 – 10

Agile Testing Interview Questions:

Agile Testing Interview Questions will help you to prepare for Agile Testing interviews.
Here is the list of 20 Agile Testing interview questions.
Agile Testing Interview Questions 1 – 10:
1. What is Agile Testing?
Agile testing is a software testing practice that follows the principles of an agile software development. It is an iterative software development methodology where requirements keep changing as per the customer needs.  Testing is done in parallel to the development of an iterative model. Test team receives frequent code changes from the development team for testing an application.
2. What is Agile Manifesto?
Agile manifesto defines 4 key points:
i. Individuals and interactions over process and tools
ii. Working software over comprehensive documentation
iii. Customer collaboration over contract negotiation
iv. Responding to change over following a plan
3. What are the principles of Agile Software Development?
1. Highest priority is to satisfy the customer through early and continuous delivery of business valuable software
2. Welcome changing requirements, even late in development
3. Deliver working software frequently
4. Business people and developers must work together daily without transparency throughout the project
5. Build projects around motivated individuals
6. The best form of communication is to do face-to-face conversation
7. Working software is the primary measure of progress
8. Able to maintain a constant pace
9. Continuous attention to technical excellence
10. Simplicity – the art of maximizing the amount of work not done – is essential
11. Self-organizing teams
12. At regular intervals, the team reflects on how to become more effective, then tunes and adjusts its behavior accordingly
4. What are the main roles in Scrum?
Scrum consists of three main roles:
Product Owner: Product Owner usually represents the Client and acts as a point of contact from Client side. The one who prioritizes the list of Product Backlogs which Scrum Team should finish and release.
Scrum Master: Scrum Master acts as a facilitator to the Scrum Development Team. Clarifies the queries and organizes the team from distractions and teach the team how to use scrum and also concentrates on Return on Investment (ROI). Responsible for managing the sprint.
Scrum Development Team: Developer’s, QA’s. Who develops the product. Scrum development team decides the effort estimation to complete a Product Backlog Item.
Scrum Team: A cross-functional, self-organizing group of dedicated people (Group of Product Owner, Business Analyst, Developer’s and QA’s). Recommended size of a scrum team is 7 plus or minus 2 (i.e, between 5 to 9 members in a team).
5. What approach do you follow when requirements change continuously?
In Agile methodology, change in requirement is possible. It’s not like other traditional methodologies where the requirements are locked down at the requirement phase. Every team member should be ready to handle the changes in the project.
The team should work closely with the Product Owner to understand the scope of requirement change and to negotiate to keep the requirement changes to a minimum or to adopt those changes in next sprint. Based on the requirement changes Test Team could update the Test Plan and Test Cases to achieve the deadlines. The team should understand the risk in requirement change and prepare a contingency plan. It is a best practice not to go for the automation process until requirements are finalized.
6. How is Agile Testing different to other traditional Software Development Models?
It is one of the common Agile Testing Interview Questions.
In Agile Methodology, testing is not a phase like other traditional models. It is an activity parallel to development in the Agile. The time slot for the testing is less in the Agile compared to the traditional models. The testing team works on small features in Agile whereas the test team works on a complete application after development in the traditional models.
7. When do we use Agile Scrum Methodology?
i. When the client is not so clear on requirements
ii. When the client expects quick releases
iii. When the client doesn’t give all the requirements at a time
8. What is a Sprint?
In Scrum, the project is divided into Sprints. Each Sprint has a specified time line (2 weeks to 1 month). This timeline will be agreed by a Scrum Team during the Sprint Planning Meeting. Here, User Stories are split into different modules. The end result of every Sprint should be a potentially shippable product.
9. What are Product Backlog and Sprint Backlog?
Product Backlog: Product Backlog is a repository where the list of Product Backlog Items stored and maintained by the Product Owner. The list of Product Backlog Items are prioritized by the Product Owner as high and low and also could re-prioritize the product backlog constantly.
Sprint Backlog: Group of user stories which scrum development team agreed to do during the current sprint (Committed Product Backlog items). It is a subset of the product backlog.
10. What is the difference between Burn-up and Burn-down chart?
Burn Down Charts provide proof that the project is on track or not. Both burn-up and burn-down charts are graphs used to track the progress of a project.
Burn-up charts represent how much work has been completed in a project whereas Burn-down chart represents the remaining work left in a project.
Agile Testing Interview Questions 11 – 20:
11. What are the types of burn-down charts?
There are four popularly used burn down charts in Agile.
i. Product burn down chart
ii. Sprint burn down chart
iii. Release burn down chart
iv. Defect burn down chart
12. What is Product Burn down Chart?
A graph which shows how many Product Backlog Items (User Stories) implemented/not implemented.
13. What is Sprint Burn down Chart?
A graph which shows how many Sprints implemented/not implemented by Scrum Team.
14. What is Release Burn down Chart?
A graph which shows List of releases still pending, which Scrum Team have planned.
15. What is Defect Burn down Chart?
A graph which shows how many defects identified and fixed.
16. What is a Daily Stand-up Meeting?
Daily Stand-up Meeting is a daily routine meeting. It brings everyone up to date on the information and helps the team to stay organized.
Each team member reports to the peers the following:
1. What did he/she do yesterday
2. What are the impediments faced
3. What he/she will do today
In general, it’s not a recorded meeting. Reporting will be between peers not to Scrum Master or Product Owner. It is normally timeboxed to a maximum of 15 minutes. It is aka 15 Minute Stand-up Meeting
17. What is a Sprint Planning Meeting?
The first step of Scrum is Sprint Planning Meeting where the entire Scrum Team attends. Here the Product Owner selects the Product Backlog Items (User Stories) from the Product Backlog.
Most important User Stories at the top of the list and least important User Stories at the bottom. Scrum Development Team decides and provides the effort estimation.
18. What is a Sprint Review Meeting?
In the Sprint Review Meeting, Scrum Development Team presents a demonstration of a potentially shippable product. Product Owner declares which items are completed and not completed. Product Owner adds the additional items to the product backlog based on the stakeholder’s feedback.
19. What is a Sprint Retrospective Meeting?
Scrum Team meets again after the Sprint Review Meeting and documents the lessons learned in the earlier sprint such as “What went well”, “What could be improved”. It helps the Scrum Team to avoid the mistakes in the next Sprints.
20. What is a Task Board?
A task board is a dashboard which illustrates the progress that an agile team is making in achieving their sprint goals.
In general, the columns used in a task board are as follows
i. User Story: Actual Business Requirement (Description)
ii. To Do: All the tasks of current sprint
iii. In Progress: Any task being worked on
iv. To Verify: Tasks pending for verification
v. Done: Tasks which are completed

Wednesday, 17 May 2017

Roles and Responsibilities

Roles and Responsibilities

Roles and Responsibilities: (Selenium)
  • Identify Test cases for Automation.
  • Developing methods for repeating steps.
  • Writing scripts, executing test cases and debugging.
  • Prepare automation scripts in Selenium WebDriver.
  • Designing Automation Framework and Implementing Automation Framework.
  • Regression Testing, support and reviewing Test scripts.
  • Data driving Test script.
  • Defect reporting, Executing Framework and Analyzing Result.
  • Preparing script execution report.
  • Responsible for guiding juniors.

Thursday, 6 April 2017

how-to-find-duplicate-words-in-string


======How To Find Duplicate Words In String==========


public class DuplicateWordsInString
{
public static void main(String[] args)
{
String test = "This sentence contains two words, one and two";
Set<String> duplicates = duplicateWords(test);
System.out.println("input : " + test);
System.out.println("output : " + duplicates);
 }
/** * Method to find duplicate words in a Sentence or String * @param input String * @return set of duplicate words */
 public static Set<String> duplicateWords(String input)
{
 if(input == null || input.isEmpty()){
return Collections.emptySet();
 }
 Set<String> duplicates = new HashSet<>();
 String[] words = input.split("\\s+");
 Set<String> set = new HashSet<>();
 for(String word : words){ if(!set.add(word))
{
duplicates.add(word);

}
 }
 return duplicates;
}
 }
Output : input : This sentence contains two words, one and two
output : [two]

how-to-find-duplicate-words-in-string

Sunday, 19 March 2017

Top 16 Java Inheritance Interview questions for freshers and experienced

1.what is inheritance?
  • inheritance is one of the oops concepts in java.inheritance is concept of  getting properties of one class object to another class object.
  • Inheritance represents the IS-A relationship,also known as parent-child relationship.
2.what are the types of inheritance?

1.Multiple inheritance( java doesn't support multiple inheritance).
2.Multilevel inheritance.

3.How Inheritance can be implemented in java?
  • Inheritance can be implemented in JAVA using below two keywords:
1.extends
2.implements
  • extends is used for developing inheritance between two classes and two interfaces.
  • implements keyword is used to developed inheritance between interface and class.
4.Why we need to use Inheritance?

1.For Code Re usability.
2.For Method Overriding.

5.what is syntax of inheritance?

public class subclass extends superclass{

//all methods and variables declare here
}

6.what is multilevel inheritance?
  • Getting the properties from one class object to another class object level wise with different priorities.

6.what is Multiple inheritance?why Java Doesn't Support multiple Inheritance.
  • The concept of Getting the properties from multiple class objects to sub class object with same priorities is known as multiple inheritance.
  • In multiple inheritance there is every chance of multiple properties of multiple objects with  the same name available to the sub class object with same priorities leads for the ambiguity. also known as diamond problem. one class extending two super classes.
  • Because of multiple inheritance there is chance of the root object getting created more than once.
  • Always the root object i.e object of object class hast to be created only once.
  1. Because of above mentioned reasons multiple inheritance would not be supported by java.
  2. Thus in java a class can not extend more than one class simultaneously. At most a class can extend only one class.
8.How do you implement multiple inheritance in java?
  • Using interfaces java can support multiple inheritance concept in java. in java can not extend more than one classes, but a class can implement more than one interfaces.
Program:

interface A{

}
interface B{
}
class C implements A,B{
}

9.Can a class extend itself?

  • No,A class can't extend itself.

10.What happens if super class and sub class having same field name?


  • Super class field will be hidden in the sub class. You can access hidden super class field in sub class using super keyword.

Wednesday, 1 March 2017

Finding Largest String in ArrayList

Finding Largest String in ArrayList

package com.java.exp;

import java.util.ArrayList;

public class HighestCharinString {

public static void main(String[] args) {

ArrayList<String> al=new ArrayList<>();
al.add("Bangalore");
al.add("hyd");
al.add("jagan");
al.add("upenderathota");
//I would set your largestString variable to your first String that you add:
int largeststring=al.get(0).length();
int index=0;
for(int i=0;i<al.size();i++)
{
//Then you should use the following to check for the largest String:
if(al.get(i).length()>largeststring)
{
largeststring=al.size();
index=i;
}
}
System.out.println("Index " + index + " "+ al.get(index) + " " + "is the largest and is size " + largeststring);


}

}
//OUTPUT:Index 3 upenderathota is the largest

Tuesday, 28 February 2017

PrintDaimond program in java

package com.java.exp;

public class Diamond {
public static void main(String[] args)
{
int i, j, k;
for(i=1;i<=5;i++)
{
for(j=i;j<5;j++)
{
System.out.print(" ");
}
for(k=1;k<(i*2);k++)
{
System.out.print("*");
}
System.out.println();
}
for(i=4;i>=1;i--)
{
for(j=5;j>i;j--)
{
System.out.print(" ");
}
for(k=1;k<(i*2);k++)
{
System.out.print("*");
}
System.out.println();
}
}


}

OUTPUT::


        *
      * * * 
    * * * * *
  * * * * * * *
* * * * * * * * *
  * * * * * * *
    * * * * *
      * * *
        *

Tuesday, 7 February 2017

Difference between throw and throws in java


throw keyword:
  • throw keyword used to throw user defined exceptions.(we can throw predefined exception too)
  • If we are having our own validations in our code we can use this throw keyword.
  • For Ex: BookNotFoundException, InvalidAgeException (user defined).

Program:
  1. package com.instanceofjava;
  2. public class MyExceptionThrow {
  3.  
  4.  public static void main(String a[]){
  5.  
  6.  try{
  7.  
  8. MyExceptionThrow thr = new MyExceptionThrow();
  9. System.out.println("length of INDU is "+thr.getStringSize("INDU"));
  10. System.out.println("length of SAIDESH is "+thr.getStringSize("SAIDSH"));
  11. System.out.println("length of null string is "+thr.getStringSize(null)); 
  12.  
  13.  }
  14. catch (Exception ex){
  15.   System.out.println("Exception message: "+ex.getMessage());  
  16.  }
  17.  }
  18.  
  19.  public int getStringSize(String str) throws Exception{
  20.  
  21.  if(str == null){
  22.    throw new Exception("String input is null");  
  23.  }
  24.  return str.length();
  25. }
  26.  
  27. }


Output
length of INDU is 4
length of SAIDESH is 5
Exception message: String input is null

throws keyword:

  •  The functionality of throws keyword is only to explicitly to mention that the method is proven transfer un handled exceptions to the calling place.

Program:
  1. package com.instanceofjava;
  2. public class ExcpetionDemo {
  3.  
  4. public static void main(String agrs[]){
  5.  
  6. try
  7. {
  8. //statements
  9. }
  10. catch(Exception e)
  11. {
  12. System.out.println(e);
  13. }
  14. finally(){compulsorily executable statements
  15. }
  16. }
  17.  
  18. }

Tuesday, 24 January 2017

Closing All Tabs Using Robot Class In Selenium WebDriver

Closing All Tabs Using Robot Class In Selenium WebDriver

Earlier we have used java robot class to save Image from page In THIS POST. Robot class Is useful to send key-press and key-release events. We will use same thing here to perform keyboard ALT + SPACE + "c" (Shortcut key)  key-press events to close all tabs of browser. We can perform this key-press event sequence very easily using Robot class. I am suggesting you to use always WebDriver's driver.quit(); method to close all tabs of browser. Intention of this postIs to make you more aware about Robot class usage with selenium WebDriver so you can perform such tricky actions 
easily whenever required.

Bellow given example has used Robot class In @AfterTest methodto close browser tabs using ALT + SPACE + 'c' key-press event sequence. Run It In your eclipse IDE to check how It works.


package Testing_Pack;

import java.awt.AWTException;
import java.awt.Robot;
import java.awt.event.KeyEvent;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;

public class Tabs {

 WebDriver driver;
 Robot rb;

 @BeforeTest
 public void setup() throws Exception {
  driver = new FirefoxDriver();
  driver.manage().window().maximize();
  driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
  driver.get("http://use any website try ur self");
 }

 @Test
 public void openTab() {  
  driver.findElement(By.cssSelector("body")).sendKeys(Keys.CONTROL +"t");
  driver.get("http:try your own");
  switchToTab();
  driver.findElement(By.xpath("//input[@id='6']")).click();
  driver.findElement(By.xpath("//input[@id='plus']"));
  driver.findElement(By.xpath("//input[@id='3']"));
  driver.findElement(By.xpath("//input[@id='equals']"));
  
  switchToTab();
  driver.findElement(By.xpath("//input[@name='FirstName']")).sendKeys("hi");
  driver.findElement(By.xpath("//input[@name='LastName']")).sendKeys("test");
  
  switchToTab();
  String str = driver.findElement(By.xpath("//input[@id='Resultbox']")).getAttribute("value");
  System.out.println("Sum result Is -> "+str);
 } 

 public void switchToTab() {  
  driver.findElement(By.cssSelector("body")).sendKeys(Keys.CONTROL +"\t");  
  driver.switchTo().defaultContent();  
 }

 @AfterTest
 public void closeTabs() throws AWTException {
  //Used Robot class to perform ALT + SPACE + 'c' keypress event.
  rb =new Robot();
  rb.keyPress(KeyEvent.VK_ALT);
  rb.keyPress(KeyEvent.VK_SPACE);
  rb.keyPress(KeyEvent.VK_C);
 }
}

Monday, 23 January 2017

Difference between Collections and Collection in java with example program

Difference between Collections and Collection in java with example program

Famous java interview question: difference between collections and collection in java
Major difference between Collection and Collections is Collection is an interface and Collections is a class.
Both are belongs to java.util package
Collection is base interface for list set and queue.
Collections is a class and it is called utility class.
Collections utility class contains some predefined methods so that we can use while working with
Collection type of classes(treeset, arraylist, linkedlist etc.)
Collection is base interface for List , Set and Queue.


Collection vs Collections

public interface Collection<E>
extends Iterable<E>


public class Collections
extends Object

Collections utility class contains static utility methods so that we can use those methods by using
class name without creating object of Collections class object
Lest see some methods of Collections class.


addAll: public static <T> boolean addAll(Collection<? super T> c,T... elements)
reverseOrder: public static <T> Comparator<T> reverseOrder()
shuffle: public static void shuffle(List<?> list)
sort:public static <T extends Comparable<? super T>> void sort(List<T> list)
How to Relate Collection and Collections
ArrayList is a Collection type of class means it is implementing Collection interface internally
Now lets see a java example program to sort ArrayList of elements using Collections.sort() method.

public class ArrayList<E>
extends AbstractList<E>
implements List<E>, RandomAccess, Cloneable, Serializable


1.Basic Java example program to sort arraylist of integers using Collections.sort() method

package com.javasortarraylistofobjects;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;

public class SortArrayListExample{

public static void main(String[] args) {

//create an ArrayList object
 ArrayList<Integer> arrayList = new ArrayList<Integer>();
     
 //Add elements to Arraylist
arrayList.add(10);
arrayList.add(7);
arrayList.add(11);
arrayList.add(4);
arrayList.add(9);
arrayList.add(6);
arrayList.add(2);
arrayList.add(8);
arrayList.add(5);
arrayList.add(1);
     
     
 System.out.println("Before sorting ArrayList ...");
 Iterator itr=arrayList.iterator();
     
while (itr.hasNext()) {

System.out.println(itr.next());
   
}

     
 /*
 To sort an ArrayList object, use Collection.sort method. This is a
  static method. It sorts an ArrayList object's elements into ascending order.
*/
  Collections.sort(arrayList);
   
  System.out.println("After sorting ArrayList ...");
     
 
     
Iterator itr1=arrayList.iterator();
     
while (itr1.hasNext()) {

System.out.println(itr1.next());
         
}
 

}
}



Output:

Before sorting ArrayList ...
10
7
11
4
9
6
2
8
5
1
After sorting ArrayList ...
1
2
4
5
6
7
8
9
10
11

Wednesday, 4 January 2017

How to Automate Radio button and Checkbox in Selenium webdriver

How to Automate Radio button and Checkbox in Selenium webdriver


                      HTML For Checkbox



                   <input type=”checkbox”>

                     For Radio Button

                    <input type=”radio”>

Automate radio button and checkbox in selenium
When you inspect these elements via firebug and firepath you will get above html type.

The main difference between radio button and checkbox is checkbox you can select multiple but for radio button, only one selection is possible.

In Selenium we have 1 method called click() to perform click events.

This click() method you can apply with radio button, checkbox, links and sometime with dropdown as well.

Let us get started

Demo Code


WebElement ele=driver.findElement(By.id());
ele.click();

WebElement ele=driver.findElement(By.id());
ele.click();

In this example I have used id only but if you want to make you script stable then you should use Xpath and CSS in your script.

Before performing click action, sometimes we need to verify some activity as well, take some example

You need to verify whether radio button or checkbox is enabled.
You need to verify whether radio button or checkbox is Displayed on UI or not.
You need to verify whether checkbox and radio button is default selected or not.
Above validations are must used in script because automation is all about validation only. You will get these type of questions in interviews also.

These words looks quite big while listening but we can easily verify this using some predefined method in Selenium.

These methods are


isDisplayed();

isEnabled();

isSelected();

isSelected();
Therefore, you must be eager now how to use these methods in script so let us see these methods using a single program.



Program to Automate radio button and checkbox in selenium

 import org.openqa.selenium.By;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.WebElement;

import org.openqa.selenium.firefox.FirefoxDriver;

public class FacebookDropdown {

     public static void main(String[] args) throws Exception {

          WebDriver driver=new FirefoxDriver();

          driver.manage().window().maximize();

          driver.get("http://www.facebook.com");

         WebElement male_radio_button=driver.findElement(By.id("u_0_e"));

         boolean status=male_radio_button.isDisplayed();

         System.out.println("Male radio button is Displayed >>"+status);

          boolean enabled_status=male_radio_button.isEnabled();

          System.out.println("Male radio button is Enabled >>"+enabled_status);

        boolean selected_status=male_radio_button.isSelected();

          System.out.println("Male radio button is Selected >>"+selected_status);

          male_radio_button.click();

        boolean selected_status_new=male_radio_button.isSelected();

          System.out.println("Male radio button is Selected >>"+selected_status_new);

     }

}


 import org.openqa.selenium.By;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.WebElement;

import org.openqa.selenium.firefox.FirefoxDriver;

public class FacebookDropdown {

     public static void main(String[] args) throws Exception {

          WebDriver driver=new FirefoxDriver();

          driver.manage().window().maximize();

          driver.get("http://www.facebook.com");

         WebElement male_radio_button=driver.findElement(By.id("u_0_e"));

         boolean status=male_radio_button.isDisplayed();

         System.out.println("Male radio button is Displayed >>"+status);

          boolean enabled_status=male_radio_button.isEnabled();

          System.out.println("Male radio button is Enabled >>"+enabled_status);

        boolean selected_status=male_radio_button.isSelected();

          System.out.println("Male radio button is Selected >>"+selected_status);

          male_radio_button.click();

        boolean selected_status_new=male_radio_button.isSelected();

          System.out.println("Male radio button is Selected >>"+selected_status_new);

     }

}
 Explanation- If you notice above scenario before click Selected status was false but after click status changed to TRUE.

Output:
Male radio button is display>>>true
Male radio button is Enable>>true
Male radio button is selected>>false
Click on radio button
Male radio button is selected>>True