Web Elements - Question 3 SwissCows : Selenium.Clear method doesn’t work.

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15498
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Web Elements - Question 3 SwissCows : Selenium.Clear method doesn’t work.

Post by ChrisGreaves »

This is an easy one, and the answer is probably a simple “YES”:-

My code has run through two search engines quite well (Bing and DuckDuckGo) and now for the third “SwissCows”.
The code has to issue two searches (for “1” and for “2”) just to prove that everything is hooked up properly so that I can institute greater tests down the road. I reason that I should be able to crawl before I try to run, so to issue two searches before I try to issue hundreds of searches.

Code: Select all

For lngSearchTerm = 1 To lngcMaxTries
    mydriver.FindElementById(strValue).Clear
    mydriver.FindElementById(strValue).SendKeys (lngSearchTerm)
    mydriver.SendKeys mydriver.Keys.Enter
Next lngSearchTerm
This is my code stripped down; lngcMaxTries is set to 2 right now, but later on it will be set to 100 or so.
I operate on the web element's search box located by class, id, or name, by:-
(a) issuing a Selenium .Clear to clear the previous contents of the search box
(a) issuing a Selenium .Sendkeys to load the contents of the search box
(a) issuing a Selenium <Enter> to send the search box off to the search engine.

I pass through the loop just twice. On the first pass the search box is empty, is loaded with 1, and the search results come back to me.
20211101_03.png
On the second pass, the “1” ought to be cleared, to disappear, before the “2” is loaded.
This works for Bing and DuckDuckGo, but in SwissCows the “1” is not cleared and I end up searching for “12” rather than “2”. If I looped to 3, I would end up searching for “123”, which is not at all what I want.

The Bing and DuckDuckGo cases suggest that my VBA program logic is correct, so this is a Selenium problem, right? And I should trot over to the Selenium forums?

Thanks
Chris
You do not have the required permissions to view the files attached to this post.
An expensive day out: Wallet and Grimace