1

On website https://opensource-demo.orangehrmlive.com/ I am trying to open the Admin box then the UserManagment and then click on Users. I do not understand where is my mistake. It gives me error AttributeError: move_to requires a WebElement. I have read other related questions like mine but still I can't get the job done.

from selenium import webdriver
from selenium.webdriver import ActionChains
from selenium.webdriver.common.by import By
import time

driver=webdriver.Chrome(executable_path="D:\ChromeDriverExtracted\chromedriver")
driver.get("https://opensource-demo.orangehrmlive.com/")
driver.maximize_window()
time.sleep(2)

driver.find_element_by_id("txtUsername").send_keys("Admin")
driver.find_element_by_id("txtPassword").send_keys("admin123")
driver.find_element(By.ID, "btnLogin").click()

admin=driver.find_elements_by_xpath("//*[@id='menu_admin_viewAdminModule']/b")
userManagment=driver.find_elements_by_xpath("//*[@id='menu_admin_UserManagement']")
users=driver.find_elements_by_xpath("//*[@id='menu_admin_viewSystemUsers']")
time.sleep(1)


actions=ActionChains(driver)
actions.move_to_element(admin).move_to_element(userManagment).move_to_element(users).click().perform()  
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
NikaTheKilla
  • 115
  • 2
  • 11

1 Answers1

2

To login within OrangeHRM, Mouse Hover on Admin then Mouse Hover on User Management and finally to click on Users you you need to induce WebDriverWait for the visibility_of_element_located() and you can use the following Locator Strategies:

driver.get("https://opensource-demo.orangehrmlive.com/")
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "input#txtUsername"))).send_keys("Admin")
driver.find_element(By.ID, "txtPassword").send_keys("admin123")
driver.find_element(By.ID, "btnLogin").click()
ActionChains(driver).move_to_element(WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "a#menu_admin_viewAdminModule")))).perform()
ActionChains(driver).move_to_element(WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "a#menu_admin_UserManagement")))).perform()
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "a#menu_admin_viewSystemUsers"))).click()

Browser Snapshot:

OrangeHRM_Login_UserManagement_Users

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352