0

I am doing automation on the following :-enter image description here

The comments you see(<!---->) , changes when I hover over the INFY(in green on the left) enter image description here

(See one of the comment changes to <span class = "actions"...)

What I performing for this(via python and selenium):

try:
# wait 10 seconds before looking for element
    INFYSYMB = WebDriverWait(driver, 10).until(
        EC.presence_of_element_located((By.XPATH, "/html/body/div[1]/div[2]/div[1]/div/div[2]/div/div[4]/div/div"))
                                                    
    )
except:
    # else quit'
    print("Not done")
    driver.quit()

action =  ActionChains(driver)
action.move_to_element(INFYSYMB)

Which hovers over it. Now I would like to click on the B. For it I need to inspect its xpath or id or some information to store that element to perform click() action on it.

But if I move my mouse, it reverts back to <!---->. So how do I copy its xpath?

4
  • It seems unclear to me what you're trying to do. You should be able to click a button without worrying about hover state. Or, are you wanting to get the text of the hover element?
    – Lee Jensen
    Mar 14 at 20:14
  • In the first image you see there is no buy button (one with Blue colored "B" in second).I want to be able to access this button (which becomes available when I hover over infy stock) Mar 15 at 7:15
  • 1
    Can you use the console to trigger the mouseover state of that element? Mar 15 at 21:33
  • thanks that worked awsomely! Mar 17 at 6:41

1 Answer 1

1

I think that I understood, and I had similar problem sometimes. So in this case I make a screenshoot and I take the xpath. Advice you need to use xpath simpler, use descendant,... Later I think you will have a new problem because this element only it's activated when the mouse is on the button, so you will need to use the library Actions ( https://medium.com/analytics-vidhya/python-selenium-all-mouse-actions-using-actionchains-197530cf75df) to move it

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.