2021年5月1日星期六

Finding XPath without using inspecting element?

I am making an automation for download data from a weather institution.

The issue is that in my effort to make it more independent I am trying to make Selenium to Tab keys to a certain spot, so the Browser focus can "Walk" to the download button. When I call the click() function it doesn't do anything. So I tried to Extract the XPath with the function get_attribute("xpath") but it returns None. How I can extract the XPath?

I am going to paste the issue down here:

Bandera=driver.find_element_by_xpath('/html/body/div[2]/div[2]/div/div[3]/div/div/div/div[1]/div/div/div[2]/div/table/tbody/tr[1]/td[1]/div/input')    Bandera.click()    Bandera.click()    ## So Here i just select and dis-select a checkbox just to be near the Download button.    actions = ActionChains(driver)  actions.send_keys(Keys.TAB * 1 )  actions.perform()    #Here i just tabed to the button    Accion=driver.switch_to.active_element    #Maybe, here is when i lost the focus of the button?    Descarga_Actual=Accion.get_attribute("xpath")  

Thank you and sorry to borrow your time.

https://stackoverflow.com/questions/67351995/finding-xpath-without-using-inspecting-element May 02, 2021 at 08:26AM

没有评论:

发表评论