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?

JavaBeigner
  • 608
  • 9
  • 28
user2122600
  • 51
  • 2
  • 8

1 Answers1

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.

Andrey Egorov
  • 1,249
  • 1
  • 12
  • 9
  • 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. – user2122600 Aug 26 '14 at 05:21
  • 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](http://stackoverflow.com/questions/15679451/javascript-form-validation-based-on-php-session-variables) will help – Andrey Egorov Aug 26 '14 at 05:32