I'm struggling to click this html element/locate it using selenium in python on this website:
After you scroll down press B and then Biology the pop up menu shown in the attached screenshot with "Biology (2018)" and "Biology" buttons are the desired elements and here is the html code for the "Biology (2018)" button:
<li data-ng-repeat="modalSubject in subject.subjectsList | orderBy:'-title'" class="ng-scope">
<a tabindex="0" data-ng-keypress="handleKeyPress($event)" data-ng-click="setExamSeriesUrl(modalSubject);">
<h3 class="ng-binding">Biology (2018)</h3>
<div class="description ng-binding"></div>
</a>
</li>
How do I locate this element and click it?
I tried this to locate and click the element but to no avail with a timeout error(despite me using time.sleep()
to give it a long enough lag for the element to appear/show up):
xpath = '//li[contains(.//h3, "{}")]'
formatted_xpath = xpath.format(Subject+" (2018)")
element = wait.until(EC.visibility_of_element_located((By.XPATH, formatted_xpath)))
element.click()