#100DaysOfWeb in Python Transcripts
Chapter: Day 49: Selenium
Lecture: Test #5: testing changing nav links upon logout
0:01 In this final test video, we're going to logout the user.
0:05 Clicking the logout link we verified
0:07 that the navigation link is down to one, which is login.
0:13 Finally we checked the HTML
0:15 if there's a message logged out.
0:21 First we're going to target the logout link.
0:25 From memory it's called logout.
0:29 Let me verify that, it indeed is logout
0:32 and we're going to just find that by the name of the link.
0:40 Because it doesn't have an ID or CSS class.
0:48 So we find it, this will work
0:50 because we're using the driver login fixture.
0:55 Which gets us into a logged in state.
1:00 So in that case there should be a logout link
1:03 which you're going to click
1:05 and then we're going to grab the page source.
1:09 And we can do that with the page_source attribute
1:14 and then we can assert that logged out is in the source.
1:35 And that failed because I have to use link text
1:41 because element by name we used for
1:43 an input field that had a name set.
1:46 So here we want to use the link text, let's try it again.
2:01 And that worked and secondly
2:04 you're going to check the logged out links.
2:08 And we're going to copy a bit of code
2:10 from the first test case and go to modify that.
2:16 So this is the other way around.
2:19 When I'm logged out, I should have a login button again.
2:26 So this should not trigger an exception
2:29 and let me update the message.
2:33 Should see logon link in navbar and logged out.
2:44 And for the private links they should all
2:46 raise an exception, because when I'm logged out
2:50 I should not have a log out button
2:52 I should not see the navigation links
2:55 my books and five hour challenge, because these are private.
2:59 And the message then would be
3:02 should not show private links when logged out.
3:11 Any of these should raise an exception
3:14 which is fine, if they don't, I fell through
3:17 to pytest fail with this message and the test fails.
3:21 And let's try this out.
3:34 And it worked, so that's the complete
3:37 test suite for this app.
3:39 You made 10 test cases and let's just run 'em all together.
3:44 And I will speed this up in the recording
3:48 because this will take a minute.
4:06 Awesome they all passed and that concludes
4:10 the videos on testing a web app with Selenium.
4:13 The next video we have an optional code challenge.