Selenium Type method test method failed

0 votes

I m using a JSP page in which I'm inputting the a text field. Below u can see the code

    <table>
    <tr>
        <td><input type="text" id="searchText" name="searchInput"/></td>
    </tr>
    </table>

Then I executed the test case which will verify the search input text.Below is the code

public class TestCaseExample extends SeleneseTestBase {

    @Before
    public void setup() {

       WebDriver driver = new FirefoxDriver(new FirefoxBinary(new File(
       "C:\\Program Files (x86)\\Mozilla Firefox 3.6\\firefox.exe")), new   FirefoxProfile());

        String baseUrl = "http://localhost:8080/RecipeProject/";
        selenium = new WebDriverBackedSelenium(driver, baseUrl);
     }

    @Test
    public void testCaseExample() {
       verifyTrue(selenium.isElementPresent("searchText"));
       selenium.type("searchText", "pepper");
     }
}

The verifyTrue test return true. However, selenium.type test failed with this error: com.thoughtworks.selenium.SeleniumException: Element searchText not found

Please help in this matter.

Apr 3, 2018 in Selenium by Vardy
• 2,250 points
65 views

1 answer to this question.

0 votes
In this matter ur 1st paramter should be selector i.e your searchText is not a valid xpath or CSS.
Use like selenium.type("css=input#searchText", "pepper");
Also check for the Selenium version as selenium.type(String,String) is from the Selenium 1 API.
If Selenium 2, you should use this WebElement element = driver.findElement(By.id("searchText")) and use element.sendKeys("pepper");
answered Apr 3, 2018 by Shubham
• 13,290 points

Related Questions In Selenium

+1 vote
1 answer
0 votes
2 answers

Can anyone help me that how to run Selenium WebDriver test cases in Chrome?

You first need to download chrome driver ...READ MORE

answered Aug 26 in Selenium by Abha
• 23,030 points
252 views
0 votes
1 answer

Headless ChromeDriver using Python Selenium error: Fails To Start— “DevTools request failed”

This should be because your ChromeDriver is ...READ MORE

answered Mar 29, 2018 in Selenium by nsv999
• 5,090 points
345 views
0 votes
1 answer
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,090 points
592 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,130 points
901 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,130 points
579 views
0 votes
1 answer

How to use JavaScript in selenium to click an Element?

Executing a click via JavaScript has some ...READ MORE

answered Apr 13, 2018 in Selenium by Shubham
• 13,290 points
12,227 views
0 votes
1 answer

Downloading *.jar file from http:// seleniumhq.org using Selenium WebDriver

For Selenium Standalone Server: profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/java-archive"); If downloading ...READ MORE

answered Apr 17, 2018 in Selenium by Shubham
• 13,290 points
375 views