1

I have following selenium IDE code when exported to JUnit 4 (Webdriver) returns an error.

Though It works fine when I export it as Selenium RC.

Kindly tell me the webdriver equivalent for below errors --

IDE Code :

<tr>
<td>deleteAllVisibleCookies</td>
<td></td>
<td></td>
</tr>

<tr>
<td>open</td>
<td>/index.html</td>
<td></td>
</tr>

<tr>
<td>selectFrame</td>
<td>content</td>
<td></td>
</tr>

<tr>
<td>select</td>
<td>librarySelect</td>
<td>label=XYZ Software Inc.</td>
</tr>

<tr>
<td>type</td>
<td>userNameInput</td>
<td>demoUser</td>
</tr>

<tr>
<td>type</td>
<td>passwordInput</td>
<td>demoPassword</td>
</tr>

<tr>
<td>clickAndWait</td>
<td>submitButton</td>
<td></td>
</tr>
.......
<tr>
<td>clickAndWait</td>
<td>link=Admin</td>
<td></td>
</tr>
.......

Exported Webdriver Code: [Contains Error]

@Test
public void testArchivalLogReport() throws Exception {
// ERROR: Caught exception [ERROR: Unsupported command [deleteAllVisibleCookies |  | ]]
driver.get(baseUrl + "/index.html");
// ERROR: Caught exception [ERROR: Unsupported command [selectFrame | content | ]]
// ERROR: Caught exception [Error: locator strategy either id or name must be specified explicitly.]
// ERROR: Caught exception [Error: locator strategy either id or name must be specified explicitly.]
// ERROR: Caught exception [Error: locator strategy either id or name must be specified explicitly.]
// ERROR: Caught exception [Error: locator strategy either id or name must be specified explicitly.]
// ERROR: Caught exception [ERROR: Unsupported command [selectFrame | relative=up | ]]
// ERROR: Caught exception [ERROR: Unsupported command [selectFrame | menu | ]]
driver.findElement(By.linkText("Admin")).click();
// ERROR: Caught exception [ERROR: Unsupported command [selectFrame | relative=up | ]]
// ERROR: Caught exception [ERROR: Unsupported command [selectFrame | content | ]]
driver.findElement(By.xpath("//td[11]/span/b")).click();
// ERROR: Caught exception [Error: locator strategy either id or name must be specified explicitly.]
// ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=content | ]]
// ERROR: Caught exception [ERROR: Unsupported command [selectFrame | name=content | ]]
// Warning: verifyTextPresent may require manual changes
try {
  assertTrue(driver.findElement(By.cssSelector("BODY")).getText().matches("^[\\s\\S]*Data Extract[\\s\\S]*$"));
} catch (Error e) {
  verificationErrors.append(e.toString());
}
// ERROR: Caught exception [ERROR: Unsupported command [selectFrame | relative=up | ]]
// ERROR: Caught exception [ERROR: Unsupported command [selectFrame | menu | ]]
driver.findElement(By.xpath("//a/font")).click();
}

Exported RC Code is Fine and looks like :

@Test
public void testArchival Log Report() throws Exception {
    selenium.deleteAllVisibleCookies();
    selenium.open("/index.html");
    selenium.selectFrame("content");
    selenium.select("librarySelect", "label=XYZ Software Inc.");
    selenium.type("userNameInput", "demoUser");
    selenium.type("passwordInput", "demoPassword");
    selenium.click("submitButton");
    selenium.waitForPageToLoad("30000");
    selenium.selectFrame("relative=up");
    selenium.selectFrame("menu");
    selenium.click("link=Admin");
..........
 }

How I am Exporting ? I am using Java/ Junit 4/ Webdriver

I can see Java/ Junit 4/ Webdriver Backed in option, Should I go with that ?? it gives me the same exported file as in Selenium RC option, only change is how we get webdriver.

3
  • Was your IDE script built using some plugins? Commented Feb 18, 2014 at 9:20
  • @MarkRowlands : No I built it manually. Commented Feb 18, 2014 at 12:52
  • 1
    The errors you're seeing are most likely due to them having a similar but no direct switch to Webdriver. Your frame change for example, would be expressed as driver.switchTo().frame() where you pass in an element or an index. The way you're exporting shouldn't matter - you'll just have to use the Webdriver api, which is fully documented, to fill in the blanks - ie, where you have those commented errors. Commented Feb 18, 2014 at 14:34

1 Answer 1

1

I figured it out using Webdriver API :

 @Test
 public void testArchivalLogReport()
    throws Exception
 {

    driver.manage().deleteAllCookies();

    driver.get(baseUrl + "/index.html");
    driver.switchTo().frame("content");
    Select library = new Select(driver.findElement(By.id("librarySelect")));
    library.selectByVisibleText("XYZ Software Inc.");
    driver.findElement(By.name("userInput")).sendKeys("username");
    driver.findElement(By.name("passwordInput")).sendKeys("password");
    driver.findElement(By.name("submitButton")).click();

    WebDriverWait wait = new WebDriverWait(driver, 120);
    wait.until(ExpectedConditions.elementToBeClickable(By
        .linkText("Admin")));

    // Store the window handle of the parent window, so that you can switch
    // back to it later.
    String wHandle = driver.getWindowHandle();

    driver.findElement(By.linkText("XYZ")).click();
    driver.findElement(By.xpath("//td[11]/span/b")).click();
    driver.findElement(By.id("someLink")).click();

    try
    {
        assertTrue(driver.findElement(By.cssSelector("BODY")).getText()
            .matches("^[\\s\\S]*Data Extract[\\s\\S]*$"));
    }
    catch (Error e)
    {
        verificationErrors.append(e.toString());
    }

    // Switch back to parent window using stored window handle
    driver.switchTo().window(wHandle);
    driver.switchTo().frame("menu");
    driver.findElement(By.xpath("//a/font")).click();

}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.