Skip to main content

Posts

Working with Dropdown in Selenium Webdriver

WebDriver has a class called “ Select ” to interact with dropdown. Dropdown is an another WebElement like textbox, radio button, links etc. We use below methods frequently to interact with Dropdown using Select class. selectByIndex(int index) selectByValue(String value) selectByVisibleText(String text) getOptions() getFirstSelectedOption() Note: Select class can be found in org.openqa.selenium.support.ui  package Sample Dropdown: selectByIndex(int index): This method is used to select dropdown value by using index. This method accept integer as an argument. Index value always start from 0 (Zero). So if we want to select 2 nd value from dropdown we have to give index 1. Syntax: Select s = new Select(dropdown_WebElement); s.selectByIndex(1); Example: package selenium; import java.util.concurrent.TimeUnit; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; ...
Recent posts

Data types in Java

Not everything in Java is an object. There is a special group of data types (also known as primitive types) that will be used quite often in programming. For performance reasons, the designers of the Java language decided to include these primitive types. Java determines the size of each primitive type. These sizes do not change from one operating system to another. This is one of the key features of the language that makes Java so portable. Java defines eight primitive types of data: byte, short, int, long, char, float, double, and boolean. 1) primitive data types 2) non-primitive data types Types Size Default Range Example boolean 1 bit false NA boolean b = true; Char 16 bits \u0000 \u0000 to \uFFFF char c = 'A'; Byte 8 bits 0 -128 to 127 byte b = 60; Short 16 bits ...

What is Agile Methodology?

Watch the below videos to get the knowledge in Agile Methodology. Part:1 Part:2

My first java program

To write a Java program we have to create a class . -> To create a class, right click on the package (Make sure you should right click on package,because you are creating class inside a package). -> Go to New . -> Click on Class .   -> In New Java Class window, enter class name in Name text box. -> If you want main method in your class click on Finish or uncheck on public static void main(String[] args) check box then click on  Finish  . -> Now write your java program. -> To run your program click on Run menu. Go to Run As , click on Java Application . -> Output will display in Console .

How to create package inside a project?

What Is a Package? A package is a namespace that organizes a set of related classes and interfaces. Conceptually you can think of packages as being similar to different folders on your computer. You might keep HTML pages in one folder, images in another, and scripts or applications in yet another. Because software written in the Java programming language can be composed of hundreds or thousands of individual classes, it makes sense to keep things organized by placing related classes and interfaces into packages. -> Right click on the Project (Make sure you should right click on project, because you are creating package inside the project). -> Go to New. -> Click on Package. -> In New Java Package window, enter package name in Name text box. -> Now click on Finish . -> Now you can see the package inside the project at Project Explorer area. Now your package is ready.

How to create Project in eclipse?

-> After open the new workspace, eclipse displaces welcome page . Close the welcome page.  Eclipse welcome page -> Now right click on Project Explorer area at left side of eclipse.   -> Go to  New , click on Project .   -> In New Project window, click on Java Project . -> Now click on Next . -> In New Java Project window, enter your project name in Project name text box. Now click on Finish . -> After click on Finish, in Open Associated Perspective? window click Yes or No . After that Make sure your perspective should be either Java or Java EE . Here i am using Java EE Perspective.   -> Here if you click Yes it opens Java Perspective, if you click No it opens Java EE Perspective. Because default Perspective is Java EE. -> We can change Perspective by clicking on Java, Java EE icons at top right. You have created project successfully.