#100DaysOfWeb in Python Transcripts
Chapter: Day 49: Selenium
Lecture: Test #5: testing changing nav links upon logout

Login or purchase this course to watch this video and the rest of the course contents.
0:01 In this final test video, we're going to logout the user. Clicking the logout link we verified that the navigation link is down to one, which is login.
0:14 Finally we checked the HTML if there's a message logged out. First we're going to target the logout link. From memory it's called logout.
0:30 Let me verify that, it indeed is logout and we're going to just find that by the name of the link. Because it doesn't have an ID or CSS class.
0:49 So we find it, this will work because we're using the driver login fixture. Which gets us into a logged in state.
1:01 So in that case there should be a logout link which you're going to click and then we're going to grab the page source.
1:10 And we can do that with the page_source attribute and then we can assert that logged out is in the source.
1:36 And that failed because I have to use link text because element by name we used for an input field that had a name set.
1:47 So here we want to use the link text, let's try it again. And that worked and secondly
2:05 you're going to check the logged out links. And we're going to copy a bit of code from the first test case and go to modify that.
2:17 So this is the other way around. When I'm logged out, I should have a login button again. So this should not trigger an exception
2:30 and let me update the message. Should see logon link in navbar and logged out. And for the private links they should all
2:47 raise an exception, because when I'm logged out I should not have a log out button I should not see the navigation links
2:56 my books and five hour challenge, because these are private. And the message then would be should not show private links when logged out.
3:12 Any of these should raise an exception which is fine, if they don't, I fell through to pytest fail with this message and the test fails.
3:22 And let's try this out. And it worked, so that's the complete test suite for this app.
3:40 You made 10 test cases and let's just run 'em all together. And I will speed this up in the recording because this will take a minute.
4:07 Awesome they all passed and that concludes the videos on testing a web app with Selenium. The next video we have an optional code challenge.


Talk Python's Mastodon Michael Kennedy's Mastodon