How to debug custom grid servlets/proxies

44 views
Skip to first unread message

Eugene Shragovich

unread,
Nov 10, 2017, 2:09:25 AM11/10/17
to Selenium Users
Hi,

I am trying making some extensions to grid functionality and created a custom proxy and servlet. I run them, from command line with -servlets and -proxy flags.
I see that they function as expected on the basic level but to continue working with them I need to be able to debug them and I'm not sure how to do that.
In a normal scenario, the hub and node are being injected with the servlet/proxy and then hub triggers a session. In case of me running the code from Eclipse, I suppose I act as a hub somehow?

I tried importing the whole project (Maven) into Eclipse and providing the same -servlets and -proxy flags in arguments section but as I feared, it didn't work and the code runs without stopping on breakpoints.


So I wanted to ask someone who also worked on custom proxies and servlets, how did you set up your Eclipse project to be able to debug your work?



Thanks in advance,
Eugene S


Krishnan Mahadevan

unread,
Nov 13, 2017, 10:11:49 PM11/13/17
to seleniu...@googlegroups.com

Eugene,

 

Here’s how you do it.

You basically build one standalone program, which spins off the hub, the node and finally runs your test code and then go about setting up breakpoints after which you can run the code in debug mode.

 

Here’s a sample that shows you what I am talking about

 

public class Launcher {
   
public static void main(String[] args) throws Exception {
       
//Start the hub
        //Add more args here to reference your new proxy/servlet
       
GridLauncherV3.main(new String[]{"-role", "hub"});

       
//Start the node
        //Add more args here to reference your new servlet
       
GridLauncherV3.main(new String[]{"-role", "node", "-hub", "http://localhost:4444/grid/register"});

        RemoteWebDriver driver =
null;
       
try {
            driver =
new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), DesiredCapabilities.chrome());
            driver.get(
"http://www.google.com");
        }
finally {
            driver.quit();
        }
    }
}

 

The other ways of debugging such as setting up remote debugging is more involved and I have personally found that the above approach is a lot more simpler and straight forward.

 

 

Thanks & Regards

Krishnan Mahadevan

 

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"

My Scribblings @ http://wakened-cognition.blogspot.com/

My Technical Scribbings @ http://rationaleemotions.wordpress.com/

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/9d56c224-a12b-441e-b623-65ee5bf1c637%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages