0

I am new with Selenium Webdriver and trying to create my first test cases for application that is constructed mostly with PHP. I am creating test cases with Java.

My first test case is testing login into the system. When I run my test, browser instance is started, login information is set into login form fields and login form is submitted. After that browser dericets to used users start page as it should. So the test works as it should.

The problem is, I would like to check if the login was successful and save it in a testing report without a need for me to see the process trough in person. I figured most valid way to ensure login success is to see if PHP code have created variable $_SESSION['logged_in'] = true as it does when login process is successful. Is there any way for me to seek through $_SESSION variables with Java in my Selenium Webdriver test class?

1 Answer 1

0

Honestly, don't know php, but in js e.g. any js variable can be recieved using next code

driver.executeScript("return someGlobalVar");

Why you need to verify exactly value of $_SESSION variable?! I think successfull login verification can be done using other ways e.g.: a. Verify that page contains some valid information related to currently logged user (e.g. name, other fields on the page) b. Verify url c. By getting response from server (or smth like this) etc. Hope this will help.

Sign up to request clarification or add additional context in comments.

2 Comments

I guess this does not help me since JS cannot access $_SESSION variables. Other ways of verifying login could be used though, as you wrote. In some other cases getting access to $_SESSION variables could be handy though, since they are widely used in the application and some test cases might need that data.
Well, then i think you can use phpunit and from it you could access $_SESSION variable. I don't know other way to access from selenium to such variable. Also i hope this link will help

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.