2

Normaly you are using selenium to automate testcases and after the testcase finished running, the browser closes.

However I try to use selenium webdriver to script specific tasks, e.g. login to a specific page but the browser should stay open after it.

I need the browser to stay open, because I developed a CMS where you can define selenium tasks and execute them. One of the tasks is to login to a backend, but I need to keep the website open forever, so that I can work in the backend. Problem: after about 20 minutes or so the browser which opened by starting the testcase, closes again.

I developed the portal so that I don't have to login to all my backends if I start working at the morning, I only have to login once into my portal and from there I can trigger everything I need.

I do it like this to login to typo3 backend (snippet):

$username_field = $SeleniumObj->byId('t3-username', true);
$pw_field = $SeleniumObj->byId('t3-password', true);
$submitButton = $SeleniumObj->byId('t3-login-submit', true);

$username_field->sendKeys("myusername");
$pw_field->sendKeys("mypasswd");
$submitButton->click();

exit;

You can see that I call exit at the end so that the "testcase" ends and the page stays open.

How to set the browser lifetime to infinite?

NOTES: I am using the latest selenium and facebook php-webdriver with custom code wrappers.

Black
  • 18,150
  • 39
  • 158
  • 271

1 Answers1

0

Testcase is to login to specific page.So, after using login credentials once login to specific page successfully, then testcase ends there. Remove exit & see.

Monali
  • 41
  • 1
  • 3
  • Sorry but you don't understand the question. I try to keep the site open I dont try to test the login form. – Black Jun 13 '17 at 07:09
  • The time a web session stays open is up to the developer of the web site. It cannot keep an inactive connection open indefinitely, and after a certain amount of time will disconnect on the server's side. The only thing you could do to keep the connection alive would be to keep interacting with it. There are third-party browser add-ins to keep pages alive if that's what you're looking to accomplish or re-invent. – Bill Hileman Jun 13 '17 at 19:39