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,370 points
192 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,380 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 in Selenium by Manoj
2,932 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
• 27,920 points
558 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,510 points
594 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,510 points
2,620 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,870 points
2,063 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,870 points
2,176 views
0 votes
2 answers

How to use JavaScript in selenium to click an Element?

JavascriptExecutor js = (JavascriptExecutor) driver;   js.execute ...READ MORE

answered Apr 1 in Selenium by anonymous
23,157 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,380 points
1,726 views