When automating password changes on VMware using Selenium in senhasegura, it is essential to create a template that interacts correctly with the VMware interface. Below is an example of how a password change template can be structured.
It is important to note that each site may have variations in its structure and fields, so it is necessary to carefully validate the specific fields of the site you are automating.
self.driver.get("https://172.66.0.145/ui")
timeout(30)
print("Open the page...")
self.driver.save_screenshot("1.png")
self.driver.find_element(By.ID, "username").send_keys("[#USERNAME#]")
self.driver.find_element(By.ID, "password").send_keys("[#CURRENT_PASSWORD#]")
print("Putting username and password")
timeout(3)
self.driver.save_screenshot("2.png")
self.driver.find_element(By.ID, "submit").click()
print("Authenticating...")
timeout(10)
self.driver.save_screenshot("3.png")
print("Accessing the change password page...")
self.driver.find_element(By.CSS_SELECTOR, ".user-menu-large > span").click()
self.driver.find_element(By.LINK_TEXT, "Change Password").click()
timeout(5)
self.driver.save_screenshot("4.png")
print("Putting values...")
self.driver.find_element(By.ID, "currentPassword").send_keys("[#CURRENT_PASSWORD#]")
self.driver.find_element(By.ID, "newPassword").send_keys("[#NEW_PASSWORD#]")
self.driver.find_element(By.ID, "confirmPassword").send_keys("[#NEW_PASSWORD#]")
timeout(5)
self.driver.save_screenshot("5.png")
print("Saving...")
self.driver.find_element(By.CSS_SELECTOR, ".btn:nth-child(2)").click()
timeout(5)
self.driver.save_screenshot("6.png")
print("Doing logoff...")
self.driver.find_element(By.CSS_SELECTOR, ".user-menu-large > span").click()
#element = self.driver.find_element(By.LINK_TEXT, "My Preferences")
#actions = ActionChains(self.driver)
#actions.move_to_element(element).perform()
self.driver.find_element(By.LINK_TEXT, "Logout").click()
timeout(10)
self.driver.save_screenshot("7.png")
print("Validating new password...")
self.driver.find_element(By.ID, "username").send_keys("[#USERNAME#]")
self.driver.find_element(By.ID, "password").send_keys("[#NEW_PASSWORD#]")
self.driver.find_element(By.ID, "submit").click()
timeout(10)
self.driver.save_screenshot("8.png")
print("Validating if the new password matches...")
self.driver.find_element(By.CSS_SELECTOR, ".user-menu-large > span").click()
print("Yes! Success....")
timeout(5)
self.driver.save_screenshot("9.png")
print("Doing new logoff...")
self.driver.find_element(By.LINK_TEXT, "Logout").click()
timeout(10)
self.driver.save_screenshot("10.png")
self.driver.close()