0

I'm trying to fill this form and can't really select the dropdown options, link https://opensource-demo.orangehrmlive.com/web/index.php/admin/saveSystemUser

I also can't use select because there is no select tag in the HTML code

user_role = Select(driver.find_element(By.XPATH,"/html[1]/body[1]/div[1]/div[1]/div[2]/div[2]/div[1]/div[1]/form[1]/div[1]/div[1]/div[1]/div[1]/div[2]/div[1]/div[1]"))
user_role.select_by_visible_text("Admin")

this shows an error that select cant be used on a div tag

  • Which is the drop down you are trying to interact with. Mention the steps to navigate to that page and find that drop down element. – pmadhu May 07 '23 at 13:44

1 Answers1

0

The drop down element is not build with Select tag, so Select library cannot be used to interact with the drop down.

Also the options are disappearing while trying to inspect them. Refer How can I inspect disappearing element in a browser?

Below is the code where I was able click on Admin option.

# Imports for Explicit waits
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

wait = WebDriverWait(driver,30)

driver.get("https://opensource-demo.orangehrmlive.com/web/index.php/auth/login")

# to navigate to the Add user page.
time.sleep(20)

# find all the elements for the drop down
select_elements = driver.find_elements(By.XPATH,"//i[contains(@class,'oxd-select-text--arrow')]")

# click on the first drop down
select_elements[0].click()

# Locate the Admin option from the drop down
admin_option = wait.until(EC.element_to_be_clickable((By.XPATH,"//div[@role='listbox']//span[text()='Admin']")))
admin_option.click()
pmadhu
  • 3,373
  • 2
  • 11
  • 23