Home:ALL Converter>Setproperty selenium for selenium

Setproperty selenium for selenium

Ask Time:2018-06-08T22:11:05         Author:siby21t

Json Formatter

I am a new learner to Selenium and its frameworks, need help in the following:

I had used set property as shown below in Program 1 as i was facing issues while sending keys. The keys were being sent very slow, but by using setProperty the issue was solved.

However when I split this code for testing as in Program 2, the keys are sent slow in spite of setting the property. Is there anything wrong in how I am setting it?

Program 1

public class BAU{

    public static void main(final String[] args) throws interruptedException{

        System .setProperty("webdriver.ie.driver","C:\\Selenium-Internet Explorer Driver Server v2.48.0(for 32 bit Windows IE)\\Selenium-Internet Explorer Driver Server v2.48.0(for 32 bit Windows IE)\\IEDriverServer.exe");
        WebDriver drive = new InternetExplorerDriver();
        drive.get("https:/testlogin.html");
        drive.manage().window().maximize();
        Thread.sleep(500);
        drive.findElement(By.name("i_username")).sendKeys("Abcde");
        drive.findElement(By.name("i_password")).sendKeys("Pass");
        this.drive.findElement(By.className("btnPrimary")).click();
    }
}

Program 2

public class BAU_TESTING{

    @Test(priority = 1)
    public void setProperty(){

        System .setProperty("webdriver.ie.driver","C:\\Selenium-Internet Explorer Driver Server v2.48.0(for 32 bit Windows IE)\\Selenium-Internet Explorer Driver Server v2.48.0(for 32 bit Windows IE)\\IEDriverServer.exe");
    }

    WebDriver drive = new InternetExplorerDriver();

    @Test(priority = 2)
    public void launchBrowser() throws InterruptedException {

        this.drive.get("https:/testlogin.html");
        this.drive.manage().window().maximize();
        Thread.sleep(500);
        System.out.println("Test Case 1 for launching the page has been executed");
    }

    @Test(priority = 3)

    public void loginPage() throws InterruptedException {

        this.drive.findElement(By.name("i_username")).sendKeys("Abcde");
        this.drive.findElement(By.name("i_password")).sendKeys("Pass");
        this.drive.findElement(By.className("btnPrimary")).click();
    }
}

Author:siby21t,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/50762548/setproperty-selenium-for-selenium
yy