I'm new to automation testing, so I have a question regarding the code, that I used to execute a simple test case: Check if password is masked
.
Steps:
- Open the browser;
- Enter the URL “http://practice.automationtesting.in/my-account/”;
- Click on
My Account
; - Enter some characters in the password field;
- The password field should display the characters in asterisks or bullets such that the password is not visible on the screen.
class LoginTest(unittest.TestCase):
baseURL = "http://practice.automationtesting.in/my-account/"
username = ""
password = "vq+fZ9!PpX"
driver = webdriver.Chrome()
@classmethod
def setUpClass(cls):
cls.driver.get(cls.baseURL)
cls.driver.maximize_window()
@classmethod
def tearDownClass(cls):
cls.driver.quit()
def test_pass_type(self):
lp = LoginPage(self.driver)
lp.set_password(self.password)
check_pass = self.driver.find_element_by_xpath("//*[@type='password']")
assert check_pass.is_displayed(), "Your password is masked!"
My logic:
The input type="password"
defines a password field (characters are masked). So if the password field have type password
, that means that the characters are masked by default.
Or I did it wrong? I'm sure there is another way to execute the step #5. Can someone give me an example?