Selenium-WebDriver Training ---- Is this the way to run valid and invalid test using TestNG setup?

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Selenium-WebDriver Training ---- Is this the way to run valid and invalid test using TestNG setup?

RajSelenium
I finished the 2nd video on webdriver today where you explained about webdrivers. I have a setup which works just fine. The methods below displays that method testesmqa1() succeeds because the keys are correct, however, the method testesmqa2() should fail because of the wrong keys.

When i execute the test, the results shows all 6 tests passed (6 because i am invoking Chrome and IE webdrivers also).

Is this the right way to perform this test?




public class rlTestNG extends SelTestCase {
       
        public void testesmqa1(){
                driver.get("http://esmqa1ui.realads.com/oas/login.do;jsessionid=8261B4BF5962C7CF18E141B2AF2107D4");
                driver.findElement(By.name("loginId")).sendKeys("Raj");
                driver.findElement(By.name("password")).sendKeys("#6Raj");
                driver.findElement(By.name("accountId")).sendKeys("Raj");
                driver.findElement(By.id("loginButton")).click();
        }
       
        public void testesmqa2(){
                driver.get("http://esmqa1ui.realads.com/oas/login.do;jsessionid=8261B4BF5962C7CF18E141B2AF2107D4");
                driver.findElement(By.name("loginId")).sendKeys("Raj123");
                driver.findElement(By.name("password")).sendKeys("#6Raj");
                driver.findElement(By.name("accountId")).sendKeys("Raj");
                driver.findElement(By.id("loginButton")).click();
       
        }
       
}
Reply | Threaded
Open this post in threaded view
|

Re: Selenium-WebDriver Training ---- Is this the way to run valid and invalid test using TestNG setup?

softwaretestingforum
Administrator
looks like you are always passing key as - "Raj", how is it wrong/invalid?
~ seleniumtests.com
Reply | Threaded
Open this post in threaded view
|

Re: Selenium-WebDriver Training ---- Is this the way to run valid and invalid test using TestNG setup?

RajSelenium
The 2nd method has an invalid key "Raj123". Only the first method has valid keys to login.

Thanks :)
Reply | Threaded
Open this post in threaded view
|

Re: Selenium-WebDriver Training ---- Is this the way to run valid and invalid test using TestNG setup?

softwaretestingforum
Administrator
ok my bad.
I am curious why you are using sendKeys API thrice. Please elaborate.
~ seleniumtests.com
Reply | Threaded
Open this post in threaded view
|

Re: Selenium-WebDriver Training ---- Is this the way to run valid and invalid test using TestNG setup?

RajSelenium
To answer your question why I am sending keys thrice, I think because I lack testing techniques :)

To tell you the truth, I am a beginner in automation, and am not being creative to test. I would appreciate if you can guide me to the right direction. My goal regarding this post is:

Say, there is a user with the following attributes:
- ID, Password, First Name, Last Name, Address Line 1, Address Line 2, Zip/Postal, State, Country

ID can not have more than 128 characters, and there are other limitations for each attribute.

Making a long story short, I was trying to see if the methods that I tried earlier will work to get the expected results.

Any advice from you is greatly appreciated!

Reply | Threaded
Open this post in threaded view
|

Re: Selenium-WebDriver Training ---- Is this the way to run valid and invalid test using TestNG setup?

softwaretestingforum
Administrator
Sorry I missed to see that you are passing data to three different fields.
By ID, if you are referring to "loginId" in the following line -

                driver.findElement(By.name("loginId")).sendKeys("Raj123"); 

then you are still passing only 6 characters which seem well within the limit of 128 characters, is not it?
~ seleniumtests.com