bibiki 18 Posting Whiz

hey there everyone. I hope you're all well.
Alright, I am working on testing a project using Selenium. I know that this is a Java forum and not a Selenium one, but I am used to using this one so I am starting here. Plus, I am very confident that the question is one that the Java experienced guys here must have come across and do have an answer.

I need to test a Login page. I am using the Page Object pattern. There are two possibilities: one, that the log in succeeds, and two, that the log in fails.

I have a LoginPage.logIn(String user, String password) method that would ideally return a DashboardPage upon successful log in. But in case of a failed log in, it should return a LoginPage. Now, I know I can make my LoginPage.logIn() method to return a supertype of both, and then in my test code I can use

assertEqual(returnedPage instanceof (one or the other), true);

What do you guys think? Should I go this way or do you have a better way?
Also, the application that I am testing is accessibale by different roles. Some roles see some dashboard links some do not. What is the best way to test for these. Should I write test methods dependent on users I pass in, and only assert the presence and absence of links relative to the users I am using in the test, or do you have someother way? Anybody that has had any experience, please share your thoughts. Thanks a lot in advance.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.