Skip to main content

Posts

Showing posts from April, 2017

How To Send Report In Mail Using Java In Selenium Web driver

Today we will share code how to send any type of selenium report in mail using java. For sending the email using JavaMail API, you need to load the two jar files: mail.jar activation.jar package SeleniumNew; import java.util.Properties; import javax.activation.DataHandler; import javax.activation.DataSource; import javax.activation.FileDataSource; import javax.mail.*;  import javax.mail.internet.*;  public class SendEmail {     public static void main(String[] args)     {                 String host="smtp.gmail.com";          final String user="ashishxx@gmail.com";//change accordingly          final String password="XXX";//change accordingly                    /*String[] to={"AshishXX@gmail.com","Ashishxxx@gmail.com"};           String[] cc={};           String[] bcc={};         */           String to="ashishxx@gmail.com";//change accordingly                     //Get the session object            Properties props = new

Read data from Properties file in Selenium

Java properties file is used to store project configuration data or settings. In this blog, we will show you how to read and write to/from a properties file. In this blog we are going to read username and password from properties file(.config)  Step 1 :- Create config.properties file in Java project  Navigate to File menu -> New -> Click on File Step 2:- Write some data in config.properties file Step 3 :- Create Java class to read properties file  Example how preform login using properties file in Seleniuim  : import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.util.Properties; import java.util.concurrent.TimeUnit; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; public class ReadProper  {   public static Properties prop;   public static void main(String[] args) throws Exception   {

Integrate/Setup Selenium Webdriver in eclipse

In this blog we are going to learn how to install Selenium webdriver in eclipse. Step 1:-Install Java and Eclipse on your computer   To Download and install latest version of Java . Click here Download java as per your system configuration. After download completed , run the .exe to install Java on your machine. If somethings wrongs to install java Please follow this link.  Click here Step 2 :- Install Eclipse   ​ ​ Download "Eclipse IDE for Java Developers" . Click here   There are several releases of Eclipse.I would suggest install Eclipse Luna due to maven inbuilt feature.  If your system is 32 bit then click on 32 bit else click on 64 bit . After download completed extract downloaded  file. ​ ​ To run Eclipse IDE click on eclipse exe file. ​ ​ Step 3 - Download the Selenium Java Client Driver ​ ​ Download Selenium standalone server and Selenium java.  Click her e Download highlighted  jar and extract conten

Firepath and firebug Add-ons installation in Mozilla

Firepath and Firebug are very useful Firefox add-on. We need to download and install Firepath and firebug to get xpath quickly in selenium. Firebug is the most famous add-on for the FireFox browser. It gives you control over the document object model of the web page so that you can modify, manage, and monitor the CSS, HTML, and JavaScript in real-time. Install Firebug in Mozilla  Step 1 :- Navigate to the link: - https://addons.mozilla.org/en-us/firefox/addon/firebug/ ​ ​ Step 2 -: Click on the button 'Add to Firefox' and  click on install button   Install FirePath in Mozilla   FirePath :- This plugin extends the capability of the FireBug add-on. It brings the options to modify, inspect and produce XPath and the CSS Selector locators. Step 1 :- Navigate to the link: - https://addons.mozilla.org/en-us/firefox/addon/firepath/ ​ ​ Step 2 :- Click on the button 'Add to Firefox' and  click on install button ​ ​   Step 3 :-No

Handle radio button & Check Boxes in Selenium

The main difference between Radio button and Checkbox is that, using radio button we will be able to select only one option from the options available. whereas using checkbox, we can select multiple options. Selenium WebDriver supports Radio Button and Radio Group controls using the WebElement class. We can select and deselect the radio buttons using the click() method of the WebElement class and check whether a radio button is selected or deselected using the isSelected() method. Before performing the click on the Radio buttons or check boxes we will have to verify follwing scenarios :- If Radio button or Checkbox is displayed on the webpage If Radio button or Checkbox is enabled on the webpage Check the default selection of the Radio button or Checkbox We use predefined methods present in selenium to handle check Box and Radio  button :- isDisplayed() isEnabled() isSelected() 1.  isDisplayed () this method returns a Boolean value, if it returns t