Apr-21-2019, 07:44 AM
(This post was last modified: Apr-21-2019, 07:44 AM by leviathan54.)
Hi All
I'm playing around with the following site (python 37/Selenium).
http://www.demo.guru99.com/V4/index.php
When i type in an incorrect password or username. I get a popup/alert.
I cant understand how to find element of the popup so i can select "ok" in the popup. I know about the find_element commands but when i open the inspector i cant see the elements of the popup.
If I understand the documentation correctly the following line would work
driver.switch_to_alert().accept without pointing it any particular element but
when i plug it into pycharm the following seems to happen driver.[strike]switch_to_alert[/strike]().alert() (i.e. strikethough in the switch_to_alert).
I played around with the line driver = driver.switch_to_alert(). It looks like it has strike though when i place it below the following line self.driver() but has no strikethough if i place it above the following line line self.driver() in line 3 (all in the same def function.)
In the code snippet below - i enter the username/password. If it is correct (ie line 18 it is passed) but if incorrect username or password (ie the else condition in line 21) i need to be able to press ok on the alert that popsup.
Can someone explain how i get around this?
I'm playing around with the following site (python 37/Selenium).
http://www.demo.guru99.com/V4/index.php
When i type in an incorrect password or username. I get a popup/alert.
I cant understand how to find element of the popup so i can select "ok" in the popup. I know about the find_element commands but when i open the inspector i cant see the elements of the popup.
If I understand the documentation correctly the following line would work
driver.switch_to_alert().accept without pointing it any particular element but
when i plug it into pycharm the following seems to happen driver.[strike]switch_to_alert[/strike]().alert() (i.e. strikethough in the switch_to_alert).
I played around with the line driver = driver.switch_to_alert(). It looks like it has strike though when i place it below the following line self.driver() but has no strikethough if i place it above the following line line self.driver() in line 3 (all in the same def function.)
In the code snippet below - i enter the username/password. If it is correct (ie line 18 it is passed) but if incorrect username or password (ie the else condition in line 21) i need to be able to press ok on the alert that popsup.
Can someone explain how i get around this?
def test_login_valid(self): driver = self.driver driver.get('http://www.demo.guru99.com/V4/') path = "C://FireFoxProfile/login1.xlsx" rows = spreadsheet.getRowCount(path, 'Sheet1') login = LoginPage(driver) #loop to extract username and password from spreadsheet and enter into website demo.guru for r in range(2, rows + 1): username = spreadsheet.readData(path, "Sheet1", r, 1) password = spreadsheet.readData(path, "Sheet1", r, 2) login.enter_username(username) login.enter_password(password) login.click_login() #if username and Passwork then check page is loaded, else fail page if driver.title == "Guru99 Bank Manager HomePage": print("test is passed") spreadsheet.writeData(path, "Sheet1", r, 3, "test passed") else: print("test failed") spreadsheet.writeData(path, "Sheet1", r, 3, "test failed") # return to homepage and insert password/username for next row in spreadsheet driver.switch_to_alert().accept #whats the issue with this line? I need to click OK on the # alert/popup time.sleep(2)I would be so grateful if someone can point me in right direction.