0

I want to control webpage with selenium and python

Python code;

menu = browser.find_element_by_css_selector(".nav")
hidden = browser.find_element_by_link_text('Soluton')
element = browser.find_element_by_xpath("//div[@class=\"two-columns\"]")
Option 1: ActionChains(browser).move_to_element(menu).click(hidden)
Option 2 : ActionChains(browser).move_to_element(element).click(hidden)

html code;

Please visit this image

I want to click "Solution" button under the nav menu.

However, Solution be in under the nav menu. So it's hidden.

so, I type following codes ;

 Option 1:

ActionChains(browser).move_to_element(menu).click(hidden)

 Option 2 :

ActionChains(browser).move_to_element(element).click(hidden)

But selenium not happen anything and not give any error message. How can I click a button under nav menu with selenium ?

Thanks

2
  • Although I'm not completely certain, from what I can guess at through the html, you might have to click on the .icon-ellipsis-h to make the sub actions menu visible. Can't really say much though, since I'm assuming most of the hover-visibility stuff is controlled through javascript on that page. Commented Dec 17, 2017 at 12:02
  • @WiggyA. thanks. i tried only find <a href element. i missed <i object. resolved my issue Commented Dec 17, 2017 at 19:26

2 Answers 2

2

If I have understood your Question and your Requirement we need to Mouse Hover over the WebElement with text as Actions where 2 options pops out as Request and Solution and you want to click() on Solution. To achieve that you can use the following code block :

#import
from selenium.webdriver.common.action_chains import ActionChains
#code block
menu = driver.find_element_by_xpath("//a[@class='incident-action']/i[@class='icon-ellipsis-h']")
ActionChains(driver).move_to_element(menu).perform()
driver.find_element_by_xpath("//div[@class='action-list' and @id='header-actions-list']//a[@class='icon-arrow' and contains(text(),'Solution')]").click()
Sign up to request clarification or add additional context in comments.

Comments

0

You can try to click Actions to make actions list visible and then click on required Solution option:

from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait as wait
from selenium.webdriver.support import expected_conditions as EC

actions = wait(driver, 10).until(EC.element_to_be_clickable((By.LINK_TEXT, "Actions")))
actions.click()
solution = wait(driver, 10).until(EC.element_to_be_clickable((By.LINK_TEXT, "Solution")))
solution.click()

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.