Showing posts with label Advanced TestNG. Show all posts
Showing posts with label Advanced TestNG. Show all posts

How to handle Select in Selenium


Example of using Select in Selenium 

public static void main(String[] args) throws InterruptedException {
WebDriver driver = new FirefoxDriver();
driver.get("https://www.mobikwik.com/");
driver.manage().window().maximize();
driver.findElement(By.xpath("//*[@id='mobile_number']")).sendKeys("9910979218");
driver.findElement(By.xpath("//*[@id='mobile_amount']")).sendKeys("10");
WebElement operator = driver.findElement(By.xpath("//*[@id='mobile_operator']"));
Select option = new Select(operator);
option.selectByVisibleText("Idea");
Thread.sleep(5000);
driver.close();
}

TestNG Error Codes


We write automation framework using TestNG and when we run it we get errors sometimes. So, it becomes important for us to know about error messages. 

I have put some of the error messages that we get when we go wrong and execute TestNG XML file:

1.If two tests are having the same name then we see below error

at org.testng.TestNG.checkTestNames(TestNG.java:981)
at org.testng.TestNG.sanityCheck(TestNG.java:970)
at org.testng.TestNG.run(TestNG.java:1002)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:109)

2.If the testname doesnot enclosed in double quotes("") then we get below error