0

How can I get the times from the following elements? I am using Selenium Webdriver and coding in C#. Both elements have the same class name?

[![From Inspect][1]][1]

On this page, https://www.yelp.com/biz/teds-montana-grill-aurora-aurora?osq=Teds+Montana+Grill

I need to gather the times displayed next to 'Today' [![Today][2]][2]

to perform the following. ``

driver.FindElement(By.ClassName("nowrap"))...

This does not have getText as a method?



  [1]: https://i.stack.imgur.com/tHwT2.png
  [2]: https://i.stack.imgur.com/EQtxZ.png

RSSregex
  • 179
  • 7

1 Answers1

1

This is of course very brittle to any changes yelp makes to their HTML but you can just execute javascript:

document.getElementsByClassName("biz-hours")[0].getElementsByClassName("u-space-r-half")[0].innerText

Example js execute with the C# driver Execute JavaScript using Selenium WebDriver in C# .

adotout
  • 1,170
  • 12
  • 17