Home > Software design >  Click item timing out selenium, python
Click item timing out selenium, python

Time:09-23

Can anyone please explain to me why this is timing out I am trying to click a button on a webpage that opens a little pop-up window.

This is the code I am using

DotXpath='//*[@id="clipboardenabled"]/div/pv-accounts-actions-manager/pv-accounts/pv-accounts-splitter/cyb-splitter/div/div[1]/pv-accounts-grid/cyb-server-data-table/div[1]/ag-grid-angular/div/div[2]/div[1]/div[3]/div[3]/div/div/div/div/cyb-actions-col/div/cyb-more-items-trigger-action-menu/cyb-floating-container/div/span/span/cyb-more-items-trigger/button/span'

Submit = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH,DotXpath)))
Submit.click()

Don't know if it'll help but here is the code from developer tools

enter image description here

I'm very new to selenium so help would be greatly appreciated

########################################

---------------------------EDIT--------------------------

#######################################

It seems the button is not visible at first (I am trying to click the ellipse) enter image description here

But once I hover over a column in the table it becomes visible

enter image description here

So I attempted to simulate the hover using the below code

xpath='//*[@id="clipboardenabled"]/div/pv-accounts-actions-manager/pv-accounts/pv-accounts-splitter/cyb-splitter/div/div[1]/pv-accounts-grid/cyb-server-data-table/div[1]/ag-grid-angular/div/div[2]/div[1]/div[3]/div[2]/div/div/div/div[1]'
elem = driver.find_element("xpath", xpath)
hover = ActionChains(driver).move_to_element(elem)
hover.perform()

Where I am attempting to hover over the Access Request column enter image description here

But the find_element() cant find the element. Error below

NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="clipboardenabled"]/div/pv-accounts-actions-manager/pv-accounts/pv-accounts-splitter/cyb-splitter/div/div1/pv-accounts-grid/cyb-server-data-table/div1/ag-grid-angular/div/div2/div1/div3/div1/div/div/div/div/i"}

CodePudding user response:

Try with following xpath to identify the element.

//button[@aria-label='more items']

code:

DotXpath="//button[@aria-label='more items']"
Submit = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH,DotXpath)))
Submit.click() 

If you still getting timeout error. May be for couple of reasons.

1.element may not be visible on the page. you need to either scroll to page to make it visible and then click or you can use javascript executor to click.

Submit=WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//button[@aria-label='more items']"))) 
driver.execute_script("arguments[0].click();", Submit)

2.The element may present inside an iframe. if that so you need to switch to iframe first, then able to click on the element.

 driver.switch_to.frame("framename")
 DotXpath="//button[@aria-label='more items']"
 Submit = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH,DotXpath)))
 Submit.click() 
  • Related