0

New to Python Selenium and I want to select the 3rd:

<div class = "inner-TPBYkbxL" ...> 

from the below 3 <div> classes with the same class name. I'm not sure what is meant by

<... "data-is-fake-main-panel" =  "true" or "false"> 

after

<div class = "inner-TPBYkbxL" ...>

Snapshot:

Div Class Structure

How should I structure my selenium web driver script? I've tried the below:

driver.find_element_by_xpath("//div[@class='inner-TPBYkbxL']").click()

But it returned:

selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable
tospipdev
  • 1
  • 2
  • It turns out that the element I need to select is
    but it also has an element with the exact same name below
    – tospipdev Mar 09 '23 at 22:33

1 Answers1

0

Generally <div> elements aren't interactable barring some exceptational conditions. Hence when you invoke click() on the <div> element identified by:

driver.find_element_by_xpath("//div[@class='inner-TPBYkbxL']")

You are facing:

selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable

This usecase

Not that super clear why you would click a <div> element. However to identify the the element:

<div class = "inner-TPBYkbxL" data-is-fake-main-panel="false"> 

you can use either of the following locator strategies:

  • Using CSS_SELECTOR:

    element = driver.find_element(By.CSS_SELECTOR, "div,inner-TPBYkbxL[data-is-fake-main-panel='false']")
    
  • Using XPATH:

    element = driver.find_element(By.XPATH, "//div[@class='inner-TPBYkbxL' and @data-is-fake-main-panel='false']")
    
  • Note : You have to add the following imports :

    from selenium.webdriver.common.by import By
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • Thanks for the clear explanation! I actually want to use selenium to click on the "down arrow" button (which will launch a drop-down menu) as shown in the top left area of the screenshot above. Therefore I believe I would need to select all the previous div classes first before I can actually perform the click() on the (2nd element from the bottom of the screenshot)? FYI - I've been getting the "element not interactable" error message if I do a direct click() via XPATH for – tospipdev Mar 09 '23 at 09:47
  • Possibly you are correct and it seems like a seperate issue. Feel free to raise a new question with your new requirement. – undetected Selenium Mar 09 '23 at 09:52
  • Hi @undetected-selenium, could you kindly take a look at a related question here in the case of selecting the 1st div class with the 2nd one having the same name https://stackoverflow.com/questions/75689880/how-to-select-the-1st-div-class-with-two-div-classes-with-the-same-name – tospipdev Mar 09 '23 at 22:38