skip to Main Content

I am trying to select an element to click it on a page (https://twitchtracker.com/riotgames/games). The element is a selectable date on a calendar pop-up.

It is

<div class="day unit in-range" data-time="1698822000000">1</div>.

Is there any way to select the element using the data-time="1698822000000" element.

I’ve tried using By.CSS_SELECTOR but I always obtain a ‘Unable to locate element’ error.

2

Answers


  1. you can use the get_attribute function to get the tag value from the selenium web element like this:

    element= driver.find_element(By.XPATH,"//div[@class='day unit in-range']")
    date_time=element.get_attribute('date_time')
    
    Login or Signup to reply.
  2. element = driver.find_element(By.CSS_SELECTOR, "div.day.unit.in-range")
    date_time = element.get_attribute('data-time')
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search