Monday, August 24, 2015

How to automate way2sms using selenium

Hello Techienthu! In this post, I would like to explain you, how to automate message sending process in Way2SMS.


In order to automate message sending process of Way2SMS, I have used most popular web application test automation tool called SELENIUM. I used Java library of Selenium API.

To understand this tutorial, you should have basic knowledge of JAVA. Please go through some java tutorials before referring this post.


Please add the below mentioned JAR files under project JAVA build path before executing this program.
  • Selenium Server standalone Java API || Link || This API contains all the required Interfaces, Classes and methods of Selenium.
  • TestNG || Link || This API contains all the Annotations and utilities of TestNG framework.

package com;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.Test;

public class Way2smsTest {
 @Test
 void sendSMS()
 {
  System.setProperty("webdriver.firefox.marionette", "false");
  WebDriver driver= new FirefoxDriver();
  //launch way2sms
  driver.get("http://site21.way2sms.com/content/index.html");
  driver.manage().window().maximize();
  //wait 4 seconds
  driver.manage().timeouts().implicitlyWait(4, TimeUnit.SECONDS);
  //give username
  driver.findElement(By.xpath("//input[@id='mobileNo' and @type='tel']")).sendKeys("type username here");
  //give password
  driver.findElement(By.xpath("//input[@id='password' and @type='password']")).sendKeys("type password here"); 
  //click on login
  driver.findElement(By.xpath("//i[contains(@class,'long-arrow-right')]/parent::button")).click();
  //give mobile number
  driver.findElement(By.id("mobile")).sendKeys("type recipient mobile number here");
  //enter message
  driver.findElement(By.xpath("//textarea[@id='message']")).sendKeys("Hello");
  //click on send button
  driver.findElement(By.id("sendButton")).click();
  //Logout
  driver.findElement(By.xpath("//a[@class='logout']/i")).click();
  driver.quit();  
 }
}

The above program can send a message to the recipient and performs logout from way2sms portal.

6 comments:

  1. sir could you please tell me how to automate registration in way2sms

    ReplyDelete
  2. This blog is nice and interesting. Thanks for sharing those information it is really well and good. Java SMS Script

    ReplyDelete
  3. driver.findElement(By.id("mobile")).sendKeys("**********");

    this statement is not working

    ReplyDelete
    Replies
    1. yeah, it's not working for me either

      Delete
  4. what jar files or other things do i have to paste? for this to work?

    ReplyDelete