FAQ: TDD Feature-Level Tests - Feature Test II: Exercise

This community-built FAQ covers the “Feature Test II: Exercise” exercise from the lesson “TDD Feature-Level Tests”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Web Development

Learn Testing for Web Development

FAQs on the exercise Feature Test II: Exercise

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

In the lesson, we learn that the first argument of the .setValue() method is a CSS selector, and the examples given to us are as follows:

browser.setValue('input[id=title]', title);
browser.setValue('textarea[id=poem]', poem);

If it’s a CSS selector, why cannot they be like

browser.setValue('#title', title); 
browser.setValue('#poem]', poem);

Is this valid?

I looked up the official WebdriverIO documentation on .getValue(), which however, gives a different syntax:

$(selector).setValue(value)

So I’m very confused…

1 Like

Hey @masakudamatsu, did you get the answer ?

As a matter of fact the official WDIO API doc does not event mention getText() as a browser method. Instead it’s listed as a method for an element object, much like setValue.

Perhaps CC is using older WDIO which perhaps requires different syntax? Wouldn’t be the first time…

Btw. This thread is now a year old.

Hey @masakudamatsu ,
I’m also a bit confused by the WDIO documentation, unless the ‘browser’ acts as the selector mentioned in the syntax:

$(selector).setValue(value)

Not sure about this, but concerning your first question: I believe we have to identify the type of HTML element we intend to set a value to (input, or textarea in the example given) and then identify it with an ID. I just assumed that is the reason why we cannot use a simple #selector here:

browser.setValue('input[id=title]', title);
browser.setValue('textarea[id=poem]', poem);

And yes, this thread is old and Codecademy does not seem to have moderators go through it, sadly. But I’m always thinking it could help out newer students who go through the course and forums.

1 Like

Reviving this old thread as I have the exact same question as you all. Too bad that @codecademy does not seem to care about this forum. Anyway …

I got confused as well bc I completed the “Learn JavaScript Unit Testing” (which is a pre requisite for this one) and noticed that the exercises were all using the selectors like this:

browser.setValue('#title', title); 
browser.setValue('#poem]', poem);

I tried to complete the lesson using the aforementioned code, but it was not accepted by codecademy’s system.

I will keep working on this course and do some research to find out what would be the correct way to use "browser.setValue( ) .

Cheers!

1 Like