I am trying to expand a list with Selenium WebDriver for Python, which is controlled by a button that looks like this:
To give you an idea of how it looks when open:
The HTML looks like this:
<div> ##just for more information on the tree
<div> ##
<ul> ##
<li>
role = "presentation"
ng-if = "session.hasOccurrences" ## this is the name of a span
class = "expand-children ng-scope"
<button
role = "button"
class = "icon-button has tooltip"
bb-translate-attrs = "{aria-label ': 'session.session-list.toggle-occurrences-aria'}"
aria-pressed = "false"
ng-click = "expand()"
aria-label = "Toggle session occurrences">
</button>
</li>
</ul> ##
</div> ##
</div> ##
Since it had a tag name "button", I tried to use the following but it did not work:
url = 'Example.com'
driver = webdriver.Chrome()
driver.get(url)
driver.find_element_by_tag_name("button").click()
I tried to use xpath and CSS selectors, which I have very minimal experience with. Is there something I could do to expand the list?
Thank you for your help in advance.
UPDATE 6/6/2020
My life became difficult because there was JS on the web page I am trying to access. One of the changes this JS makes is that it hides some of the elements' paths. It is strange; on the web page they are accessible and clickable, but no XPATH can locate them.
I tried to outsmart this by locating an accessible element on the page using ActionChains, then tabbing into the element I want to access and click it. But when I reach the element by tabbing, I can't click it. I printed the element to see what Python sees, and it sees "None". Is there any workaround to this?