Image of the table I want to use
So I wanted to get a specific value of the table, from a particular row and column, but there's no <table> in the inspect sheet, and I can't seem to find a way to retrieve my required result.
My requirement is: Checking how many users are there and how many are enabled/disabled
The XPATH that I have given below might be wrong, because I tried various XPATH configurations nothing worked, so maybe I am doing something wrong
Please check my code below and help me or guide me how can I solve this, thank you.
import time
from selenium import webdriver
from selenium.webdriver.common.by import By
driver = webdriver.Chrome()
driver.implicitly_wait(10)
driver.get("https://opensource-demo.orangehrmlive.com/web/index.php/auth/login")
driver.maximize_window()
driver.find_element(By.XPATH, "//input[@placeholder='Username'\]").send_keys("Admin")
driver.find_element(By.XPATH, "//input[@placeholder='Password'\]").send_keys("admin123")
driver.find_element(By.XPATH, "//button[@class='oxd-button oxd-button--medium oxd-button--main orangehrm-login-button']").submit()
time.sleep(3)
driver.find_element(By.XPATH, "/html\[1\]/body\[1\]/div\[1\]/div\[1\]/div\[1\]/aside\[1\]/nav\[1\]/div\[2\]/ul\[1\]/li\[1\]/a\[1\]").click()
rows = len(driver.find_elements(By.XPATH, "(//div\[@class='oxd-table-card'\])"))
print("Total Number Of Rows:" + rows)
count = 0
for r in range(1, rows + 1):
status = driver.find_element(By.XPATH,"(//div[@role='row'])[2]").text
status = driver.find_element(By.XPATH, "//div[@class='orangehrm-container']").text
status1 = driver.find_element(By.XPATH, "(//div\[contains(text(),'Disabled')\])").text
if status == "Enabled":
count = count + 1
else:
if status1 == "Disabled":
count = count + 1
print("Total Number of Users:" + rows)
print("Total Number of Enabled Users:" + count)
print("Total Number of Disable Users:" + (rows - count))
driver.quit()
As I said we have 3 requirements:
- Checking how many users we have
- Checking how many of then are disabled
- Checking how many users are enabled