Saturday, June 3, 2017

Automate way2sms using selenium with python

Hello Techienthu!!
Here in this post i automated way2sms message sending process using selenium with python, please go through the code below.
If you just check the code, It is quite easy to write script using python when compared to java.
Please click on the below link to navigate to way2sms using java:
 http://seleniumautomationeasy.blogspot.in/2015/08/how-to-automate-way2sms-using-selenium.html
from selenium import webdriver
import os
'''Way2sms automation using python'''
class Way2Sms():
    url = "http://site24.way2sms.com/content/index.html"
    username = "yourusername"
    password = "yourpassword"
    mobilenum = "receivermobilenumber"
    message = "Hi There! automated using selenium python"
    confirmationMessageExpected = "Message has been submitted successfully."
    driver = webdriver.Firefox()
    driver.get(url)
    driver.maximize_window()
    driver.implicitly_wait(4000)
    '''Login to Way2Sms'''
    driver.find_element_by_xpath("//input[@id='username']").send_keys(username)
    driver.find_element_by_xpath("//input[@id='password']").send_keys(password)
    driver.find_element_by_xpath("//input[@id='loginBTN']").click()
    '''Send SMS'''
    driver.find_element_by_xpath("//a[normalize-space()='Send SMS']").click()
    driver.switch_to_frame("frame")
    driver.find_element_by_xpath("//input[@id='mobile']").send_keys(mobilenum)
    driver.find_element_by_xpath("//textarea[@id='message']").send_keys(message)
    driver.find_element_by_xpath("//input[@id='Send']").click()
    confirmationMessageActual = driver.find_element_by_xpath("//div[@class='wrap MES']//child::span").text
    if confirmationMessageActual != confirmationMessageExpected:
        raise AssertionError("There is a problem in message sending process")
    '''logout'''
    driver.switch_to_default_content()
    driver.find_element_by_xpath("//li[@class='lout']").click()
    driver.close()
    driver.quit()

1 comment:

  1. It is not working after reaching to link SEND SMS

    ReplyDelete