I'm scraping Tradingview. On that website is this chart:

I'm trying to double click the red circled element on the chart. When my code tries to double click it, it doesn't get double clicked.
This is the code which I tried (it's a method inside a class):
def change_indicator_settings(self, entry, tp, sl):
# double click on the indicator
indicator = self.driver.find_elements(By.CSS_SELECTOR, 'div[data-name="legend-source-item"]')
print(indicator[0])
print(indicator[0].get_attribute('class'))
ActionChains(self.driver).double_click(indicator[0]).perform()
There is nothing wrong with my selector or the code which I'm using, so, I don't know why this isn't working.
Here is the html of the element which I'm trying to double click:
<div class="sources-131H9iuA">
<div class="item-131H9iuA last-131H9iuA blockHidden-e6PF69Df"></div>
<div class="item-131H9iuA study-131H9iuA has5Buttons-131H9iuA withTail-131H9iuA" data-name="legend-source-item"></div>
<div class="item-131H9iuA study-131H9iuA disabled-131H9iuA has5Buttons-131H9iuA" data-name="legend-source-item"></div>
</div>
Can someone tell me what I'm doing wrong and how I can fix it
Don't know about why your code doesn't work, since your code seems mostly correct and I cannot find any chart like the one you posted when I click the link.
But you can try using xpath instead of css selector:
If your CSS selector failed to find the elements, the XPATH method will find the elements.
If it didn't work because no elements were found, then the above should work.
But here there are two elements that will be selected with the above XPATH, there are possibly more. Assume there are two such elements and your code failed because you need to double click the second one, use the following:
If
ActionChains.double_clickdoesn't work, try useindicator.click()twice instead (indicator.click(); indicator.click())So there four tests you need to do. Beware some of the tests might raise exceptions, as I don't have access to the chart in question I cannot test it. But whatever exception you encounter, it means the method that caused it doesn't work. Just ignore the exception and use the other methods.