Display results as :

Rechercher Advanced Search

Latest topics
» how to connect DB in selenium webriver
Fri Oct 06, 2017 4:09 pm by anbarasi

» How find any text in browser screen and click on it?
Thu Oct 05, 2017 2:02 pm by sandeepkommineni

» Selenium Webdriver
Tue Oct 03, 2017 1:35 pm by PiyushBiswas

» GRID setup tutorial.
Wed Sep 27, 2017 4:29 pm by johnyapp

» Drag & Drop Between Windows Using Selenium Driver
Wed Sep 27, 2017 2:10 pm by 26rondel

» Check if window is closed / verify input
Sat Sep 23, 2017 10:21 pm by brainstir

» How to work on pages with AJAX in selenium?
Mon Sep 18, 2017 6:08 pm by azharuddin

» pause test until user press a key like F2
Wed Aug 09, 2017 11:10 pm by djnforce

» Selecting the input for auto populating element
Sat Jul 29, 2017 7:53 pm by kdabbara


Check if window is closed / verify input

View previous topic View next topic Go down

Check if window is closed / verify input

Post by brainstir on Sat Sep 23, 2017 10:21 pm


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:

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:
driver = webdriver.Chrome()
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>
window_after = driver.window_handles[1]
print("window after: " + window_after)
sso_login_username = driver.find_element_by_id('username')
sso_login_passwort = driver.find_element_by_id('password')
print("window current: " + driver.current_window_handle)

assert "The account or password is invalid." not in driver.page_source


Posts : 1
Join date : 2017-09-23

Back to top Go down

View previous topic View next topic Back to top

- Similar topics

Permissions in this forum:
You cannot reply to topics in this forum