'How to perform click on element that inside flexbox

I'm working on a web-scraping project , I encounter a problem that I couldn't locate the element(1H) by using find_element_by_xpath/id/css-selector/class_name and perform click()on it. Does anyone have any ideas how to make it work ? Thanks in advance!

Here's the part of my code

from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys
from selenium import webdriver
from datetime import timedelta, date
import time
import datetime
import re
import mouse

def scrape(): 
    website = 'https://www.binance.com/en/trade-margin/BTC_USDT'
    path = '/Users/admin/Downloads/chromedriver'
    driver = webdriver.Chrome(path)
    driver.get(website) 
    driver.maximize_window()
    
    #click on 1H
    actions = ActionChains(driver)
    one_hour = driver.find_element_by_xpath('//div[@class="css-e2pgpg"][@id='1h']')
    actions.click(one_hour).perform() 

Here's the html

#it is flexbox
<div class="css-e2pgpg">
<div id="Time" class="css-1pj8e72">Time</div>
<div id="15m" class="css-1pj8e72">15m</div>
<div id="1h" class="css-ktyfxp">1H</div> #i want to locate this element and perform click on it 
<div id="4h" class="css-1pj8e72">4H</div>
<div id="1d" class="css-1pj8e72">1D</div>
<div id="1w" class="css-1pj8e72">1W</div>
</div>


Solution 1:[1]

I went to see the webpage myself. In my opinion, you don't have to locate the flexbox itself.

Just try with:

driver.find_element_by_id('1h').click();

Also, I would add some kind of wait until the page loads fully. You can use Thread.sleep, implicit waits or waiting for an element.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Dharman