Selenium WebDriver to select combo-box item?

后端 未结 4 1877
情深已故
情深已故 2020-12-31 05:41

We are using Selenium WebDriver and JBehave to run \"integration\" tests on our web-app. I have a method that will enter a value into a form input.

@When(\         


        
4条回答
  •  别那么骄傲
    2020-12-31 06:18

    The Selenium paradigm is that you are supposed to simulate what a user would do in real life. So that would be either a click or a keys for navigation.

    Actions builder = new Actions( driver );
    Action  action  = builder.click( driver.findElement( By.id( elementId ) ) ).build();
    action.perform();
    

    As long as you get a working selector to feed into findElement you should have no problem with it. I have found CSS selectors to be a better bet for things involving multiple elements. Do you have a sample page?

提交回复
热议问题