how to convert slenium ide script to webdriver/testNG

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

how to convert slenium ide script to webdriver/testNG

bharath kumar
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.....

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/f1ae7eb4-95b5-44b5-a985-3c8ade0098f7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: how to convert slenium ide script to webdriver/testNG

pledgeX
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



On Saturday, October 18, 2014 5:56:26 PM UTC+1, bharath kumar wrote:
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.....

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/b3a271a4-62b3-485d-987a-412f87983932%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: how to convert slenium ide script to webdriver/testNG

Janesh Kodikara
In reply to this post by bharath kumar
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.By;
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 
http://www.seleniumhq.org/download/#side_plugins



--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/968e89c7-273c-4232-a72c-f080e33976c1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: how to convert slenium ide script to webdriver/testNG

Priyanka Saroch
In reply to this post by bharath kumar
I am unable to do it in the new version of firefox +selenium IDE... can anyone help me plz

On Saturday, October 18, 2014 at 10:26:26 PM UTC+5:30, bharath kumar wrote:
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.....

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/c69afd2c-5b5e-4ff0-a3e0-ff8bf5a7d24c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.