Selenium findElement(By.classname identifier

Hello, I
The <input name> DOM line below is similar to one that I have used this Webdriver; driver.findElement(By.className("whsOnd zHQkBf"))
to enter my username.  When I click on the button "Next," the page moves on to the page to enter the password.
This is the line for the password;
<input name="password" tabindex="0" class="whsOnd zHQkBf" dir="ltr" spellcheck="false" aria-label="Enter your password" type="password" jsname="YPqjbf" data-initial-value="" data-initial-dir="ltr" autocomplete="current-password" autocorrect="off" autocapitalize="off">

You'll see that the same class name is used, yet the driver.findElement(By.className("whsOnd zHQkBf")) is not working.
Why?  I don't see any other className or id to use.  What can be used?  The test site is
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Does it work if you just search on class 'whsOnd'?
chimaAuthor Commented:
gurpsbassi, using only half of "whsOnd zHQkBf" is an interesting thoughtt.  I solved the problem by doing a;  driver.get  of the second page.
But then I commented out this line and the line driver.findElement(By.className("whsOnd zHQkBf")).sendKeys(  continues to  work.
If I boot up, I would not be surprised if it stops working.

I'll wait to see if anyone else has any comments, before I will issue the points.
I'm not interested in points unless I solve your problem.
OWASP Proactive Controls

Learn the most important control and control categories that every architect and developer should include in their projects.

Not sure I get what you mean by using 'half'.
It's not half. There are TWO distinct class names separated by a space character
chimaAuthor Commented:
gurpsbassi maybe you can offer an explanation why the sequence of events solved the problem, yet the line of code which solved the problem is no longer needed.  I'm afraid the fix will be eliminated if and when I shutdown my computer.
The other question I have is; how does one refresh the browser, i.e., the web page with Webdriver?
Siva Prasanna KumarPrincipal Solutions ArchitectCommented:
A CSS class name can't have spaces between them, hence "whsOnd zHQkBf" is invalid CSS class name, if it was a valid CSS class name you wouldn't have encountered this issue. Thanks.

@Siva Prasanna Kumar --- there are two classes
Siva Prasanna KumarPrincipal Solutions ArchitectCommented:
@gurpsbassi: But By.className("whsOnd zHQkBf") will only accept one class name by definition.

@Chima: Why not use


unless you have two elements with same name you should be able to resolve it.
question is how can you uniquely identify the element in question.
If you really need both class names to be present then use By.cssSelector(....) where you can define a selector to match on both classnames.

Also you might want to consider shortening your search path by starting from the current element rather than top of the DOM tree.
chimaAuthor Commented:
Siva Prasanna Kuma,  I'll read the link you have provided.
In answer to your question; use driver.findElement(By.xpath("//input[@name='password']"));   I am working with MS Edge and it is not like firefox where one has firepath.  I can't "roll my own" xpath at this time.  Possibly I'll learn how later.  I was  learning that I can get xpath from firefox/firepath and use it in Edge....Is this true?  I tried it and it did not work, but I'll have to look at it again.

gurpsbassi  Your comment: use By.cssSelector(....) where you can define a selector to match on both classnames
I'll try it.  I might have a follow up question.

A comment for both of you; The site I was given to work with is/was  I had my code working, but then gmail changed their website.  The other site is/was facebook.  I do not know why it is not picking up the "login" button, and my code worked at one time.
If I have time, I'll go back to this code, but I have to move on.  If this happens, then I will issue points and close this question.
China do you understand what I've said? Do you appreciate there are multiple class names?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
chimaAuthor Commented:
gurpsbassi, Yes and I'll look into that.  I just do not have time at the moment.
Right well. Whenever you have time then.
chimaAuthor Commented:
gurpsbassi and siva, I have time today to look into this, yet I decided to close this question and open a new one if I need to.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.