- brainstir
- Posts : 1
Join date : 2017-09-23
Check if window is closed / verify input
Sat Sep 23, 2017 10:21 pm
Hello,
I login to a site.
now i want to chek, if im logged in corectly.
the login-site is a pop-up, taht is being closed if im logged in successful and if not, in page_sourceĀ "The account or password is invalid." appears.
so ive made:
but this also fails, when im logged in successfuly, because the browser switches back to the other window and it also fails, beaucse the message doesnt appear in the source_code of the successfully logged in page.
i tried to do it with windows-handles, but it seems the window handle is always the same...
how can i check this?
Code currently looks like this:
I login to a site.
now i want to chek, if im logged in corectly.
the login-site is a pop-up, taht is being closed if im logged in successful and if not, in page_sourceĀ "The account or password is invalid." appears.
so ive made:
- Code:
assert "The account or password is invalid." not in driver.page_source
but this also fails, when im logged in successfuly, because the browser switches back to the other window and it also fails, beaucse the message doesnt appear in the source_code of the successfully logged in page.
i tried to do it with windows-handles, but it seems the window handle is always the same...
how can i check this?
Code currently looks like this:
- Code:
driver = webdriver.Chrome()
driver.get("webpage")
assert "something" in driver.title
window_before = driver.window_handles[0]
print("window before: " + window_before)
login_button = driver.find_element_by_xpath('//*[@id="sso"]/button').click() #<button class="btn btn-primary" data-sso="on" autofocus="">Login</button>
time.sleep(10)
print(driver.title)
window_after = driver.window_handles[1]
driver.switch_to_window(window_after)
print("window after: " + window_after)
sso_login_username = driver.find_element_by_id('username')
sso_login_username.clear()
sso_login_username.send_keys(uname)
sso_login_passwort = driver.find_element_by_id('password')
sso_login_passwort.clear()
sso_login_passwort.send_keys(pwd)
sso_login_passwort.send_keys(Keys.RETURN)
time.sleep(10)
print("window current: " + driver.current_window_handle)
assert "The account or password is invalid." not in driver.page_source
Permissions in this forum:
You cannot reply to topics in this forum