Selenium Forum: Functional And Regression Testing Tool.
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Search
Display results as :
Advanced Search
Latest topics
AEM Training | Free Online DemoWed Apr 21, 2021 5:45 pmazharuddin
c# PageFactory - issue initializing elementsFri Nov 01, 2019 8:40 pmthegoatboy
Selenium making automatic connection to random urlsMon Jul 08, 2019 12:58 pmrepairtechsolutions1
How can we design the custom framework in Selenium RCMon Jun 24, 2019 2:26 pmrandybonnettes
What are the new features in Selenium 3.0Tue Jun 18, 2019 5:37 pmpappyvicky
What are you using Selenium for? Fri Apr 12, 2019 3:52 amzhl
LIMITATIONS OF SELENIUMWed Apr 10, 2019 11:23 amswara
Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

Go down
avatar
brainstir
Posts : 1
Join date : 2017-09-23

Check if window is closed / verify input Empty 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:

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
Back to top
Permissions in this forum:
You cannot reply to topics in this forum