Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I identify the Selenium Grid host running my test from within the test?

I am using Selenium Grid with TestNG to run my tests in parallel. I have certain tests that require a user to be logged in, so I have a user account configured for testing.

I have been careful to ensure that any tests involving logging in as my test user are run on separate virtual machines so that sessions are not interrupted, however after investigating some regularly failing tests it turns out that this is not enough. I therefore either need to:

  • Set up a new user for each test (I understand this may be the ideal solution, but it'll take some time to configure/run.

  • Have multiple test user accounts, and ensure that only one is used at a time.

If I could identify the host of the machine running the test I could set up test accounts accordingly. Is there any way to do this, or is there another solution that I haven't thought of?

like image 332
Dave Hunt Avatar asked Nov 15 '22 15:11

Dave Hunt


1 Answers

I solved the problem of identifying the remote by putting up a "who am I page". Within my remote webdriver (or Selenium) factory, I visit that page, store it in that class I use to hold the session, and log it. This page reports Host name, IP, Browser type and version.

like image 128
Precipitous Avatar answered Dec 21 '22 13:12

Precipitous