RE: How to open the application without providing login crdentials using TestNG?

Answered

Here is my scenario:
In TestNg suite we are providing some test cases in that while executing  testcases,for first test case  browser is opening and when it calls second test case again the browser is opening and asking login credentials .Is there any way pls provide solution.

surekha Train Asked on September 25, 2014 in Selenium WebDriver.
Add Comment
3 Answers

Hi Surekha,

Let us know your code and suite also and I didn’t understand your expectation. As per my understanding I am suggesting below code.

You do not want to launch 2 browsers correct?. If yes, you the below code.

If not, just use the proper Annotation.

Also go through the below link:

Link:

http://stackoverflow.com/questions/20833168/selenium-and-testng-all-test-in-one-browser

Code:

private static WebDriver driver;

@BeforeTest
public static void beforeMethod() {
driver = new FirefoxDriver();
}
@Test(priority=1)
public void main1() {
driver.get(“http://indianrail.gov.in/pnr_Enq.html”);
driver.findElement(By.id(“element”)).sendKeys(“1234567890”);
String captcha = driver.findElement(By.id(“txtCaptchaDiv”)).getText();
System.out.println(captcha);
driver.findElement(By.id(“txtInput”)).sendKeys(captcha);
}
@Test(priority=2)
public void main2() {
driver.findElement(By.className(“btn_style”)).click();
}

Doctor Answered on September 26, 2014.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.