I have make 3 function for blank data,invaliddata and validdata
i have user autoit for the upload the the file from the window.at the debug time script is run properly but at the run time it the .Below code:

[![package abc;

import java.io.IOException;

import org.openqa..By;
import org.openqa..WebElement;
import org.openqa..support.ui.Select;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;

public class Profile {

    Setup s1=new Setup();
    Login l1=new Login();

    @BeforeTest
    public void setup()
    {
        s1.openbroweser();

    }
    @Test(priority=1)
    public void profile()
    {
        s1.getdriver().get("google.com");
        WebElement email=s1.getdriver().findElement(By.name("email"));
        email.clear();
        email.sendKeys("[email protected]");

        WebElement password=s1.getdriver().findElement(By.name("password"));
        password.clear();
        password.sendKeys("heena1");

        WebElement signin=s1.getdriver().findElement(By.id("m_login_signin_submit"));
        signin.click();
    }

    @Test(priority=2)
    public void blankdata() throws InterruptedException, IOException
    {
        Thread.sleep(3000);
        WebElement pic=s1.getdriver().findElement(By.className("form-control"));
        pic.click();
        Thread.sleep(5000);
        Runtime.getRuntime().exec("C:\Users\Rutvi \Desktop\fileupload.exe");

        WebElement name=s1.getdriver().findElement(By.name("name"));
        name.clear();
        name.sendKeys(" ");

        WebElement phno=s1.getdriver().findElement(By.name("phone")); 
        phno.clear();
        phno.sendKeys(" ");

        WebElement comname=s1.getdriver().findElement(By.name("company_name"));
        comname.clear();
        comname.sendKeys(" ");

        WebElement vatno=s1.getdriver().findElement(By.name("vat_number"));
        vatno.clear();
        vatno.sendKeys(" ");

        WebElement cocno=s1.getdriver().findElement(By.name("coc_number"));
        cocno.clear();
        cocno.sendKeys(" ");

        WebElement address=s1.getdriver().findElement(By.name("address"));
        address.clear();
        address.sendKeys(" ");

        WebElement postalcode=s1.getdriver().findElement(By.name("postal_code"));
        postalcode.clear();
        postalcode.sendKeys(" ");

        WebElement provience=s1.getdriver().findElement(By.name("provincie"));
        Select dropdown= new Select(provience);
    //  dropdown.selectByIndex(3);

        WebElement save=s1.getdriver().findElement(By.id("update_user_profile"));
        save.click();       
    }

    @Test(priority=3)
    public void invaliddata() throws InterruptedException, IOException
    {

        WebElement pic=s1.getdriver().findElement(By.className("form-control"));
        pic.click();
        Thread.sleep(5000);
        Runtime.getRuntime().exec("C:\Users\Rutvi\Desktop\wrongfileupload.exe");

        WebElement name=s1.getdriver().findElement(By.name("name"));
        name.clear();
        name.sendKeys("Rutvi");

        WebElement phno=s1.getdriver().findElement(By.name("phone"));
        phno.clear();
        phno.sendKeys("9012345678");

        WebElement comname=s1.getdriver().findElement(By.name("company_name"));
        comname.clear();
        comname.sendKeys("search native");

        WebElement vatno=s1.getdriver().findElement(By.name("vat_number"));
        vatno.clear();
        vatno.sendKeys("123454");

        WebElement cocno=s1.getdriver().findElement(By.name("coc_number"));
        cocno.clear();
        cocno.sendKeys("89798");

        WebElement address=s1.getdriver().findElement(By.name("address"));
        address.clear();
        address.sendKeys("ahmedabad");

        WebElement postalcode=s1.getdriver().findElement(By.name("postal_code"));
        postalcode.clear();
        postalcode.sendKeys("1234AS");

        WebElement provience=s1.getdriver().findElement(By.name("provincie"));
        Select dropdown= new Select(provience);
        dropdown.selectByIndex(3);

        WebElement save=s1.getdriver().findElement(By.id("update_user_profile"));
        save.click();

    }

    @Test(priority=4)
    public void validdata() throws InterruptedException, IOException
    {
        Thread.sleep(3000);
        WebElement pic=s1.getdriver().findElement(By.className("form-control"));
        pic.click();

        Runtime.getRuntime().exec("C:\Users\Rutvi\Desktop\fileupload.exe");
        Thread.sleep(5000);
        WebElement name=s1.getdriver().findElement(By.name("name"));
        name.clear();
        name.sendKeys("Rutvi");

        WebElement phno=s1.getdriver().findElement(By.name("phone"));
        phno.clear();
        phno.sendKeys("9012345678");

        WebElement comname=s1.getdriver().findElement(By.name("company_name"));
        comname.clear();
        comname.sendKeys("search native");

        WebElement vatno=s1.getdriver().findElement(By.name("vat_number"));
        vatno.clear();
        vatno.sendKeys("123454");

        WebElement cocno=s1.getdriver().findElement(By.name("coc_number"));
        cocno.clear();
        cocno.sendKeys("89798");

        WebElement address=s1.getdriver().findElement(By.name("address"));
        address.clear();
        address.sendKeys("ahmedabad");

        WebElement postalcode=s1.getdriver().findElement(By.name("postal_code"));
        postalcode.clear();
        postalcode.sendKeys("1234AS");

        WebElement provience=s1.getdriver().findElement(By.name("provincie"));
        Select dropdown= new Select(provience);
        dropdown.selectByIndex(3);

        WebElement save=s1.getdriver().findElement(By.id("update_user_profile"));
        save.click();

    }

}

enter image description here



Source link https://sqa.stackexchange.com/questions/35208/display--error-in-

LEAVE A REPLY

Please enter your comment!
Please enter your name here