Python Selenium .click() Not Working but Server Response is 200

Question:

I’m having a hard time coming up with a solution. I’m writing code in Python using the Selenium library to pull reports from a site we utilize. In order to access the reports, it has to click on a link to expand so the code can find the report names. The issue I’m running into is the code is running fine and clicking on the link, but the link isn’t expanding to reveal the reports. Debugging is saying that the link is found and clicked with a post response of 200, but nothing is happening. Due to the nature of the response code saying everything is fine, I’m at a loss of why the folder isn’t expanding. Due to the nature of the site, I cannot share too much but have attached my code that I can share along with screenshots.

wait = WebDriverWait(driver_chrom, 30)

def Try_Wait(args, thing_string):
    try:
        wait.until(EC.presence_of_element_located(args))
        logger_write.debug("found element "+thing_string)
        #print("found args for ", thing_string)
        return
    except:
        Exit_LogOut()
        driver_chrom.quit()
        sys.exit()

def Button_Click(args, thing_string):
    try:
        driver_chrom.find_element(*args).click()
        logger_write.debug("Found button click"+thing_string)
        #print('clicking button for ', thing_string)
        return
    except:
        #print('did not click button ', thing_string)
        logger_write.error("Did not find button "+thing_string)
        return

thing_string = 'Opening folder for reports'
Try_Wait((By.XPATH,'//div[@id="folder1"]/table/tbody/tr//td[a[starts-with(@href, "javascript:clickOnNode(") and contains(@href, "1") and contains(text(),"Standard")]]'), thing_string)
Button_Click((By.XPATH,'//div[@id="folder1"]/table/tbody/tr//td[a[starts-with(@href, "javascript:clickOnNode(") and contains(@href, "1") and contains(text(),"Standard")]]'), thing_string)

This is what it looks like after code above runs
enter image description here

This is what it should look like so that reports are loaded into the html
enter image description here

Here is the inspect screenshot:
enter image description here

Asked By: Ryan_The_Noob

||

Answers:

Try following xpath should work for you.

//a[text()="Standard"]

Instead this

//div[@id="folder1"]/table/tbody/tr//td[a[starts-with(@href, "javascript:clickOnNode(") and contains(@href, "1") and contains(text(),"Standard")]]

Or use Link_Text since it is anchor rag

Try_Wait((By.LINK_TEXT ,"Standard"), thing_string)
Button_Click((By.LINK_TEXT ,"Standard"), thing_string) 
Answered By: KunduK