how to convert slenium ide script to webdriver/testNG

823 views
Skip to first unread message

bharath kumar

unread,
Oct 18, 2014, 12:56:26 PM10/18/14
to seleniu...@googlegroups.com
hello all,
please let me know how to convert selenium IDE script to webdriver/testNG,i am trying for this in eclipse am not getting any options in selenium IDE recording tool,help me out on it ASAP.....

pledgeX

unread,
Oct 20, 2014, 5:17:06 AM10/20/14
to seleniu...@googlegroups.com
If you open up the IDE extension in firefox, you should be able to go to File > Export Test Case/Suite As and there will be a list of languages available. E.g. Java / JUnit 4 / WebDriver

If you're not seeing any options here, then you may need to install additional language bindings.  Look for the heading: "Selenium Client & WebDriver Language Bindings" on the following web page:
http://docs.seleniumhq.org/download/#side_plugins

Janesh Kodikara

unread,
Oct 21, 2014, 12:21:52 PM10/21/14
to seleniu...@googlegroups.com
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 String BASE_URL = "http://demo.orangehrmlive.com/";
  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 



Priyanka Saroch

unread,
May 16, 2018, 9:43:43 AM5/16/18
to Selenium Users
I am unable to do it in the new version of firefox +selenium IDE... can anyone help me plz

Saba Anjum

unread,
Jan 19, 2019, 11:17:47 PM1/19/19
to Selenium Users
By any chance, did you got its solution?
Iam facing the same issue. Please suggest

Tom Bhayya

unread,
Jan 20, 2019, 11:17:13 PM1/20/19
to seleniu...@googlegroups.com
I am unable to convert it either but I am using an alternative IDE tools Katalon. This is available in both chrome and Firefox and you have turned option to convert your scripts (ide >webdriver).
Hope this is helpful. 

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/ac4a5b0a-01d9-4412-81c8-fa97090429be%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Tibor Száraz

unread,
Jan 21, 2019, 3:31:53 AM1/21/19
to seleniu...@googlegroups.com
Hi,

you can export to Java with Katalon studio plugin ,
with new Selenijm iDE it is yet not possible, at least in 3.4.4

Előre is köszönöm/Thank you in advance
Üdvözlettel
/Best regards

Tibor, Száraz
Test manager/Test engineer/Instructor
#tiborszaraz

mobil:       +36 70 278 6606
email:        tibor....@gmail.com
website:  https://uptowork.com/mycv/tiborszaraz
https://www.udemy.com/user/tibor-szaraz/           

Google Plus Icon 24x24 pngFacebook Icon 24x24 pngLinkedIn Icon 24x24 pngTwitter Icon 24x24 pngYouTube Icon 24x24 pngreddit Icon 24x24 pnghttps://www.amazon.com/gp/profile/amzn1.account.AFOMYY4PAZA7N2DRVPFLXCJVTLVQhttps://en.wikipedia.org/wiki/User:Tiborszaraz




Reply all
Reply to author
Forward
0 new messages