Thursday, March 31, 2022

Java Program Conditional Statement PART - 4

 package selenium;

public class Conditionalstatement {

public static void main(String[] args) {

int number =6;

//using ternary

System.out.println(number%2==0 ? "Even Number" : "Odd Number");

int person_age =15;

//Using Ternary Operator

System.out.println(person_age>=18 ? "Eligible for vote" : "Not eligible for vote");

//IF ELSEIF CONDITION

int num=10;

if(num>0)

{

System.out.println("Number is positive");

}

else if (num<0) 

{

System.out.println("Number is negative");

}

else if (num==0) 

{

System.out.println("Number is zero");

}

}

}


Java Program Operators PART - 3

 package selenium;

public class Operators {

public static void main(String[] args) {

//Conditional Operator - Use of Ternary operator

int age =20;

String res=(age >=18) ? "Eligible to vote": "Not eligible to vote";

System.out.println(res);

int a = 10;

int res1=++a; //pre increment   11 //first increases value of a then assignment happens

System.out.println(res1); //10

System.out.println(a);

boolean x=true;

boolean y=false;

System.out.println(x && y); // false if both values are true will return true if not false.&& - AND operator

System.out.println(x || y); // true if either one is true give true.|| - OR operator

System.out.println(!x); //false

System.out.println(!y); //true

}

}


Java Program For Data Types Part-2

 package selenium;

public class Datatypes {

public static void main(String[] args) {

//single line variable declaration

int a=10, b=20, c=30;

System.out.println(a);

        System.out.println(b);

System.out.println(c);

System.out.println(a+b); // add the a,b value

  long c1=123456789L; //Long data type

        System.out.println(c1);

    

                 int person_age=30; // Number data type

        System.out.println(person_age);

 float item_price=15.5f; //have to specify with f character if it is a float

 System.out.println(item_price);

char grade='B'; // Char data type

System.out.println(grade);

boolean status1=true;

boolean status2=false;

System.out.println(status1+" "+status2);

String person_name="Suriya Parithy"; // Name data type

System.out.println(person_name);

}

}

Java Programming Part - 1

 package selenium;
public class Firstprogram {
public static void main(String[] args) {
System.out.println("This is my first java program written by suriya"); // print statement in console
System.out.println("10+20"); //prints the string
System.out.println(10+20); //evaluates the operation
System.out.println("Welcome to Selenium");
}
}

Wednesday, March 30, 2022

Selenium WebDriver Browser Commands PART - 2

 Get Commands

  • Get commands are used to collect various information about the page that we deal with here are some important “get” commands.

1. Get-Command  - get()

  •      get() command is used to open a new browser window and it will find/fetch the page that you have given.

2. Get Title Command - getTitle() 

  • getTitle() is used to get the title of the current page.

3. Get Current URL Command -  getCurrentUrl() 

  • This command is used to get the current URL of the browser.

4. Get Page Source Command –  getPageSource() 

  • This command is used to get the source code of the page.

5. Get Text –  getText() 

  • This command is used to fetch the text of the element.

NAVIGATE COMMANDS

1. Navigate To Command–  navigate().to() 

  • This command is like Get() command.
  • It opens a new browser window and it will find/fetch the page that you have given.

2. Navigate Refresh Command–  navigate().refresh() 

  • This command is used to refresh the current page.

3. Navigate to the back page–  navigate().back() 

  • This command is used to go back by one page in the browser’s history.

4. Navigate to the forward page–  navigate().forward() 

  • Takes you forward by one page on the browser’s history.

5. Refresh page –  navigate().refresh() 

  • It refreshes the current page.

 

OTHER USEFUL COMMANDS


1. switch to command – ” driver.switchTo().window(“windowName”) ”

  • This command is used to switch from one window to another.

2. Switching  from one iframe to another – ” driver.switchTo().frame(“frameName”) ”

  • This command is used to switch from one iframe to another iframe.

3. Handling Alerts – ” driver.switchTo().alert() ”

  • This command is used to handle alerts.

4. Close Command –  close() 

  • This command closes the current window of the browser.

5. Quit Command – quit() 

  • This command is used to quit the browser and all the opened windows in the browser.