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,360 points
423 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,480 points

Related Questions In Selenium

+1 vote
2 answers

Python with Selenium issue: “Chrome is being controlled by automated test software”

from selenium import webdriver chrome_options = webdriver.ChromeOptions() chrome_options.add_experimental_option("useAutomationExtension", False) chrome_options.add_experimental_option("excludeSwitches",["enable-automation"]) driver ...READ MORE

answered Apr 20, 2020 in Selenium by Manoj
7,643 views
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, 2019 in Selenium by Abha
• 28,060 points
1,054 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 30, 2018 in Selenium by nsv999
• 5,500 points
1,000 views
0 votes
1 answer
0 votes
2 answers

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,500 points
6,053 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
6,477 views
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,890 points
4,110 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,190 points
5,078 views
0 votes
5 answers

How to use JavaScript in selenium to click an Element?

WebElement element = driver.findElement(By.id("id")); JavascriptExe ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
49,258 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,480 points
3,496 views