Follow the following steps to save a script using selenium IDE:
- Open Firefox browser.
- Open selenium IDE from Tools in browser.
- Verify the RECORD button is ON in selenium IDE window.
- Search “selenium ide” in Google.
- Verify the recorded script in selenium IDE window.
- Save the recorded script from file menu.
Command | Target | Value |
open | / | |
type | id=gbqfq | Hello Selenium |
click | id=gbqfb |
* Base URL:
http://www.google.co.in/
HTML Source code:
SaveScriptUsingSeleniumIDE | ||
open | http://www.google.co.in/ | |
type | id=gbqfq | Hello Selenium |
click | id=gbqfb |
Java Source code:
package com.helloselenium.tests; import org.openqa.selenium.*; import org.openqa.selenium.firefox.FirefoxDriver; public class SaveScriptUsingSeleniumIDE{ public static void main(String args[]) { String baseUrl = "http://www.google.co.in/"; WebDriver driver = new FirefoxDriver(); driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); driver.get(baseUrl + ""); driver.findElement(By.id("gbqfq")).clear(); driver.findElement(By.id("gbqfq")).sendKeys("Hello Selenium"); driver.findElement(By.id("gbqfb")).click(); driver.quit(); } }
JUnit Source code:
package com.helloselenium.tests; import org.junit.*; import org.openqa.selenium.*; import org.openqa.selenium.firefox.FirefoxDriver; public class SaveScriptUsingSeleniumIDE{ private WebDriver driver; private String baseUrl; @Before public void setUp() throws Exception { driver = new FirefoxDriver(); baseUrl = "http://www.google.co.in/"; driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); } @Test public void testUntitled() throws Exception { driver.get(baseUrl + ""); driver.findElement(By.id("gbqfq")).clear(); driver.findElement(By.id("gbqfq")).sendKeys("Hello Selenium"); driver.findElement(By.id("gbqfb")).click(); } @After public void tearDown() throws Exception { driver.quit(); } }
TestNG Source code:
package com.helloselenium.tests; import org.openqa.selenium.*; import org.openqa.selenium.firefox.FirefoxDriver; import org.testng.annotations.Test; import org.testng.annotations.BeforeTest; import org.testng.annotations.AfterTest; public class SaveScriptUsingSeleniumIDE{ private WebDriver driver; private String baseUrl; @BeforeTest public void setUp() throws Exception { driver = new FirefoxDriver(); baseUrl = "http://www.google.co.in/"; driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); } @Test public void testUntitled() throws Exception { driver.get(baseUrl + ""); driver.findElement(By.id("gbqfq")).clear(); driver.findElement(By.id("gbqfq")).sendKeys("Hello Selenium"); driver.findElement(By.id("gbqfb")).click(); } @AfterTest public void tearDown() throws Exception { driver.quit(); } }
0 Comments
What would you like to add in my list? I look forward to reading your comments below.