简体   繁体   中英

Get $_SESSION parameters via Java in Selenium Webdriver

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?

Honestly, don't know php, but in js eg 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 eg: a. Verify that page contains some valid information related to currently logged user (eg name, other fields on the page) b. Verify url c. By getting response from server (or smth like this) etc. Hope this will help.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM