Collections:
Convert Chrome Selenium IDE Test to Java
How to Convert Chrome Selenium IDE Test to a Java program using WebDriver client API?
✍: FYIcenter.com
If you like what you have recorded in a test with Selenium IDE for Chrome
you can follow this tutorial
to convert it a Java program using WebDriver client API,
1. Right-click the test name "Search Test". You see the context menu.
2. Click "Export" command from the context menu. You see export options.
3. Select "Java JUnit" and click "EXPORT".
4. Save the exported Java program file to a folder like "C:\fyicenter\SearchTest.java".
5. Open the saved Java program file in a text editor to review.
// Generated by Selenium IDE
import org.junit.*;
import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.core.IsNot.not;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.ui.*;
import java.util.*;
public class SearchTestTest {
private WebDriver driver;
private Map<String, Object> vars;
JavascriptExecutor js;
@Before
public void setUp() {
driver = new FirefoxDriver();
js = (JavascriptExecutor) driver;
vars = new HashMap<String, Object>();
}
@After
public void tearDown() {
driver.quit();
}
@Test
public void searchTest() {
driver.get("http://sqa.fyicenter.com/");
driver.manage().window().setSize(new Dimension(1211, 648));
driver.findElement(By.name("Q")).click();
driver.findElement(By.name("Q")).sendKeys("selenium");
driver.findElement(By.name("Q")).sendKeys(Keys.ENTER);
driver.findElement(By.xpath("(//div[@id=\'item\']/p/a/span)[6]")).click();
driver.findElement(By.linkText("What Is Selenium")).click();
}
}
As you can see, the exported Java program uses the FirefoxDriver class from the Selenium WebDriver Java API. But you can change it the ChromeDriver class if you want to.
The exported Java program also requires JUnit (open source framework to write and run unit tests in Java) package to run.
⇒ Convert Chrome Selenium IDE Test to Python
⇐ Open Saved Tests on Selenium IDE for Chrome
2019-09-04, 4066🔥, 0💬
Popular Posts:
How to access Response Status Code 400 as Success? My sampler failed, because the server returns the...
How to validate email address format? In order to help your programming or testing tasks, FYIcenter....
How to perform regular expression pattern match with multiple occurrences? To perform a regular expr...
How to generate test credit card numbers? Test credit card numbers are frequently needed in testing ...
How to see my IP address Host Name? To help you to see your IP Address Host Name, FYIcenter.com has ...