0

I have a java web application in which i have integrated some selenium code which basically does the following job : I have a login page with user name and password,so once i fill the details and click on login button, it gives call to the selenium code(java method through servlet),which opens another tab and fills the URL and the same details there on its login page. This works fine with one system.but i have to deploy the .war file in tomcat so that this should work for all the users in same way, but when i am accessing the URL from remote system and logging in ,its opening the browser on my server where my Apache is running.

So my question is how can i achieve this ? if any user access my URL and login it should open another tab in his system rather than on server.

I have tried using grid2, created a hub on server and node on remote system but still when i run my application it opens browser in server. I am not sure how can i achieve this.

there is one link i found which uses java script in chrome with node.js

[http://aboutcode.net/2013/12/02/automating-chrome-on-windows-with-javascript-using-selenium-webdriverjs.html][1]

How can i execute selenium java script code in java.

Any help will be really appreciated thank you.

Zee
  • 41
  • 2
  • 8
  • please provide the code snipet of your scripts. May be you use grid and registered your PC into the grid. – Nguyen Vu Hoang Jul 03 '15 at 04:57
  • Is this what you are looking for: http://stackoverflow.com/questions/31147889/how-to-run-a-selenium-test-from-remote-computers/31153053#31153053 – Manu Jul 03 '15 at 07:49
  • @Manu yes looks like the same,so its possible as you say if any client visit my URL form any machine the test will start in his machine instead of server machine..i am totally new to selenium..let me try your steps..i will get back with code snippet...thank you very much Manu.. – Zee Jul 03 '15 at 10:00
  • @Manu can you please share any sample code for this scenario that will help me if possible... – Zee Jul 03 '15 at 10:05
  • Sorry, won't be able to share any sample code. You can start with creating a Grid and [run test](http://code.google.com/p/selenium/wiki/Grid2#Using_grid_to_run_tests). Update the question accordingly if you are unable to still do it. – Manu Jul 03 '15 at 10:14

2 Answers2

0

This sounds like a gross misuse of the Selenium TEST framework & I urge you to rethink your approach. You can achieve everything you want to with javascript from within YOUR application, passing variables via the querystring to the new window See JavaScript: location.href to open in new window/tab?

Community
  • 1
  • 1
0

Finally able to fix the issue with grid 2

String nodeUrl = "http://"+ip+":5560/wd/hub";  

    DesiredCapabilities capability = DesiredCapabilities.internetExplorer();
    driver = new RemoteWebDriver(new URL(nodeUrl),capability);
    driver.manage().window().maximize();
    driver.manage().timeouts().implicitlyWait(2, TimeUnit.MINUTES);

To open browser on the client end,we need to pass the IP of that client from javascript to the server. And driver and selenium should be registered an running before executing the code.

Special Thanks to Manu.. :)

Community
  • 1
  • 1
Zee
  • 41
  • 2
  • 8