I am on a page in which I need to click on a variable's logo/name/arrow (3 button options). The variable is called HISCO occupation. HTML from URL: https://icem.data-archive.ac.uk/#step2:
<div class="clearfix ice-tab-wrapper" id="workhistoryunit_category" ng-class="{active:tabActive[child.name]}">
:: before
<button class="fa fa-certificate ice-icon" ng-click="toggleTab(child.name, $event)">
:: before
<span class= "sr-only ng-binding"> HISCO OCCUPATION </span>
</button>
< button .....> </button>
My entire code so far:
ETUPfrom selenium.webdriver.support.ui import WebDriverWait
import selenium
from selenium import webdriver as wd
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
chrome_path = r'C:\webdrivers\chromedriver.exe'
webD=wd.Chrome(executable_path=chrome_path)
webD.get('https://icem.data-archive.ac.uk/#step1')
## STEP 1: SELECTING A YEAR, HERE 1851
webD.find_element_by_xpath('/html/body/div/section/section[1]/article[1]/div[1]/div/div[1]/label/input').click()
## STEP 2: SELECTING ENGLAND
WebDriverWait(webD, 20).until(EC.element_to_be_clickable(
(By.XPATH, '//b[@id = "country_england"]/preceding-sibling::input'))).click()
## STEP 3: MOVE ON TO VARIABLES
webD.find_element_by_xpath('//html/body/div/section/section[1]/article[2]/div/div/button').click()
## STEP 4.1: COUNTIES, OPEN MENU
WebDriverWait(webD, 20).until(EC.element_to_be_clickable(
(By.XPATH, '//*[@id="county_category"]/button[1]'))).click()
## STEP 4.2 COUNTIES, MORE VARIABLES
WebDriverWait(webD, 20).until(EC.element_to_be_clickable(
(By.XPATH, '//*[@id="county_category"]/div[2]/div/div[2]/button'))).click()
## VERSION 1, SELECTION 1 COUNTY/ 1 HISCO_OCC
## STEP 4.3 COUNTIES, SELECT VARIABLES
WebDriverWait(webD, 20).until(EC.element_to_be_clickable(
(By.XPATH, '/html/body/div[3]/div/div/div[3]/div[1]/label/input'))).click()
## STEP 4.3.2 CLICK APPLY
WebDriverWait(webD, 20).until(EC.element_to_be_clickable((By.XPATH, "//button[contains(.,'Apply')]"))).click()
# STEP 5, HISCO OCCUPATION, OPEN MENU
WebDriverWait(webD, 20).until(EC.element_to_be_clickable((By.ID, "workhistoryunit"))).click()
As of now, I have the following (unsuccessful) code trying to click on either of these buttons:
WebDriverWait(webD, 20).until(EC.element_to_be_clickable((By.XPATH, '//*[@id="workhistoryunit_category"]/button[1]'))).click()
or
webD.find_element_by_xpath('//*[@id="workhistoryunit_category"]/button[1]').click()
The action prior to clicking this button is closing a window (applying a selection).
This code is based on the code from a previous analogous click on the same page, just another variable (hence different ID) that works:
WebDriverWait(webD, 20).until(EC.element_to_be_clickable((By.XPATH, '//*[@id="county_category"]/button[1]'))).click()
Any ideas what the problem maybe?