Categories
JavaScript Answers

How to select option in drop down Protractor e2e tests with JavaScript?

Spread the love

Sometimes, we want to select option in drop down Protractor e2e tests with JavaScript.

In this article, we’ll look at how to select option in drop down Protractor e2e tests with JavaScript.

How to select option in drop down Protractor e2e tests with JavaScript?

To select option in drop down Protractor e2e tests with JavaScript, we can select the select element and then call click on it.

For instance, we write

element(by.cssContainingText("option", "BeaverBox Testing")).click();

to select the option element that we want to pick with

element(by.cssContainingText("option", "BeaverBox Testing"))

cssContainingText lets us select by option element’s text content.

Then we call click on click on the option to select it.

Conclusion

To select option in drop down Protractor e2e tests with JavaScript, we can select the select element and then call click on it.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *