-2

HTML elements from Inspect Redfin.com

The highlighted code references the red search button with the magnifying glass to the right of the search box. I don't know which element to refer to it with Selenium webdriver FindBy. Can someone tell me the correct FindElementby and which element? Thanks!

There is no name and ID to refer to it.

Ajeet Verma
  • 2,938
  • 3
  • 13
  • 24
  • 1
    Screenshots of the UI are great, screenshots of code or HTML are not. Please read why [a screenshot of code/HTML is a bad idea](https://meta.stackoverflow.com/questions/303812/discourage-screenshots-of-code-and-or-errors). Paste the code/HTML as text and properly format it instead. – JeffC Apr 03 '23 at 21:54
  • Share the URL for this code so that we could test our code. Share the code you have tried too. – user10186832 Apr 04 '23 at 14:38
  • Welcome Reyhan! Please take some time to read the introduction to Stack Overflow and earn your Informed badge. We're a little bit different from other sites. Here's how... https://stackoverflow.com/tour – user10186832 Apr 04 '23 at 14:40
  • https://meta.stackoverflow.com/questions/285551/why-should-i-not-upload-images-of-code-data-errors – user10186832 Apr 04 '23 at 14:41

2 Answers2

0

The css selector is button[type='submit'][tabindex='0'] > svg

gords
  • 51
  • 7
  • Thanks, so is that the Findelementby to use, CSS? And which "value?" Appreciate your help. – Reyhan Nettles Apr 05 '23 at 02:32
  • That is the findby css. A quick google will get you the standard code to find it then click it – gords Apr 05 '23 at 06:21
  • I really appreciate your help but I apologize I'm a bit confused by your reply. I was just trying to verify which findbyelement out of the ones that were there was the correct one to use, since ID and name were not there, and I assumed you were saying that css was the correct element. Was my assumption correct? And I'm confused as to what I was supposed to be googling as well. Thanks I really appreciate your replys. – Reyhan Nettles Apr 05 '23 at 06:36
  • Webelements e.g. search button, can be found byid, byname, bycss, byxpath and some other ways. I have given you the css to findbycss – gords Apr 05 '23 at 10:04
0

This works for me ...

Option Explicit

Sub Test()
    Dim chr As ChromeDriver
    Dim mykeyword As String
    Set chr = New Selenium.ChromeDriver
    Call chr.Start("edge")
    chr.Get ("https://www.redfin.com")
    mykeyword = Sheet1.Cells(2, 1).Value
    chr.FindElementByName("searchInputBox").SendKeys mykeyword
    chr.Wait 1000
    chr.FindElementByCss("button[type='submit'][tabindex='0'] > svg").Click
    chr.Wait 10000
    chr.Quit
End Sub
user10186832
  • 423
  • 1
  • 9
  • 17