Hello Kumar,
You cannot use the IDE for converting the scripts into Java/WebDriver/TestNG yet. (Java/WebDriver/JUNit) is available.
You could modify Java/WebDriver/Junit into Java/WebDriver/TestNG.
Open IDE and navigate to Options --> Options
Popup window is opened
Select Formats tab
Select "Java/Junit4/WebDriver"
Set the variable for selenium instance to
webDriver
Set the destination package
e.g. com.pragmatic.automation
Remove existing code and add following to the header section
package ${packageName};
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.NoAlertPresentException;
import org.openqa.selenium.Alert;
import org.testng.Assert;
import org.testng.annotations.*;
import java.util.concurrent.TimeUnit;
public class ${className} {
private WebDriver webDriver;
private boolean acceptNextAlert = true;
private StringBuffer verificationErrors = new StringBuffer();
final int TIMEOUT_IN_SECONDS = 30;
@BeforeClass
public void setUp() throws Exception {
webDriver= new FirefoxDriver();
webDriver.manage().timeouts().implicitlyWait(TIMEOUT_IN_SECONDS, TimeUnit.SECONDS);
}
@BeforeMethod
public void beforeTest() {
webDriver.manage().deleteAllCookies();
webDriver.get(BASE_URL);
}
@Test
public void ${methodName}() throws Exception {
Remove the existing content in the footer and paste following
}
@AfterClass
public void tearDown() throws Exception {
webDriver.quit();
}
private boolean isElementPresent(By by) {
try {
webDriver.findElement(by);
return true;
} catch (NoSuchElementException e) {
return false;
}
}
private boolean isAlertPresent() {
try {
webDriver.switchTo().alert();
return true;
} catch (NoAlertPresentException e) {
return false;
}
}
private String closeAlertAndGetItsText() {
try {
Alert alert = webDriver.switchTo().alert();
String alertText = alert.getText();
if (acceptNextAlert) {
alert.accept();
} else {
alert.dismiss();
}
return alertText;
} finally {
acceptNextAlert = true;
}
}
}
Converting the test cases to Java/TestNG/WebDriver
Open IDE
File -->Export Test Case As -->Java/TestNG/WebDriver
Follow the options
Optionally you could use the "Test Suite Batch Converter" plugin to convert multiple test cases