I am trying to test scripts on the nodes of selenium grid2 but I am not able to get the logs of their execution, can anybody please help me with retrieving the logs of the remote controls in selenium grid.Thanks in advance
I am using selenium grid2 to test my scripts and my problem is that I need to extract the log of the script that is executing on a particular node of the grid and for that I have written the following code
/* THIS CODE STARTS THE HUB AND ATTACHES A NODE TO THE HUB */
import java.net.MalformedURLException; import java.net.URL; import java.util.HashMap; import java.util.Map;
import org.apache.bcel.util.ClassLoader;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
import org.mortbay.jetty.servlet.AbstractSessionManager.Session;
import org.openqa.grid.common.GridRole;
import org.openqa.grid.common.RegistrationRequest;
import org.openqa.grid.common.SeleniumProtocol;
import org.openqa.grid.internal.utils.GridHubConfiguration;
import org.openqa.grid.internal.utils.SelfRegisteringRemote;
import org.openqa.grid.web.Hub;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.server.log.LoggingManager;
import org.seleniumhq.jetty7.util.log.LoggerLog;
import org.testng.TestListenerAdapter;
import com.beust.testng.TestNG;
import com.thoughtworks.selenium.Selenium; import com.thoughtworks.selenium.condition.DefaultConditionRunner.Log4jMonitor;
public class StartHubProgrammatically
{
Hub myHub;
// static final Logger logger = Logger.getLogger(StartHubProgrammatically.class);
public static void main(String s[]) throws Exception{
StartHubProgrammatically startHub=new StartHubProgrammatically();
startHub.startHub(); } public void startHub() throws Exception{
final Logger logger = Logger.getLogger(StartHubProgrammatically.class); PropertyConfigurator.configure("log4j.properties"); GridHubConfiguration gridHubConfig = new GridHubConfiguration(); gridHubConfig.setHost("localhost"); gridHubConfig.setPort(4444); myHub = new Hub(gridHubConfig); myHub.start();
DesiredCapabilities chrome = DesiredCapabilities.internetExplorer(); chrome.setBrowserName("*iexplore"); SelfRegisteringRemote remoteWebDriverNode = attachNodeToHub(DesiredCapabilities.internetExplorer(), GridRole.REMOTE_CONTROL, 5555, SeleniumProtocol.WebDriver);
} private SelfRegisteringRemote attachNodeToHub( DesiredCapabilities capability, GridRole role, int nodePort, SeleniumProtocol protocol) throws Exception { SelfRegisteringRemote node = null; RegistrationRequest registrationRequest = RegistrationRequest .webdriverNoCapabilities(); capability.setCapability("seleniumProtocol", protocol); registrationRequest.addDesiredCapabilitiy(capability); registrationRequest.setRole(role); registrationRequest.setConfiguration(fetchNodeConfiguration(role, nodePort, protocol)); node = new SelfRegisteringRemote(registrationRequest);
node.startRemoteServer(); node.startRegistrationProcess();
return node; }
private Map fetchNodeConfiguration(GridRole role, int portToRun, SeleniumProtocol protocol) throws MalformedURLException { Map nodeConfiguration = new HashMap(); nodeConfiguration.put(RegistrationRequest.AUTO_REGISTER, true); nodeConfiguration.put(RegistrationRequest.HUB_HOST, myHub.getHost()); nodeConfiguration.put(RegistrationRequest.HUB_PORT, myHub.getPort()); nodeConfiguration.put(RegistrationRequest.PORT, portToRun); URL remoteURL = new URL("http://" + myHub.getHost() + ":" + portToRun); nodeConfiguration.put(RegistrationRequest.PROXY_CLASS, "org.openqa.grid.selenium.proxy.WebDriverRemoteProxy"); nodeConfiguration.put(RegistrationRequest.MAX_SESSION, 1); nodeConfiguration.put(RegistrationRequest.CLEAN_UP_CYCLE, 2000); nodeConfiguration.put(RegistrationRequest.REMOTE_URL, remoteURL); nodeConfiguration.put(RegistrationRequest.MAX_INSTANCES, 1); return nodeConfiguration; }
}
/* THIS IS THE TEST SCRIPT WE EXECUTE THIS SCRIPT USING TESTNG WHICH SENDS A REQUEST ON TO THE HUB AND THE HUB ROUTES THE THIS SCRIPT TO A NODE THAT IS COMPATIBLE WITH THE CONFIGURATION SPECIFIED IN THE SCRIPT */
package com.qait.testrunner1;
import java.net.MalformedURLException; import java.net.URL;
import org.testng.annotations.*; import com.thoughtworks.selenium.DefaultSelenium; import com.thoughtworks.selenium.Selenium;
public class GridWithWebdriver {
public Selenium selenium;
@Parameters( { "browser" }) @BeforeClass public void setup(String browser) { selenium = new DefaultSelenium("localhost", 4444, browser,"http://google.com"); selenium.start(); }
@AfterClass public void tearDown() { selenium.stop(); }
@Test public void test_first() { selenium.open("/"); selenium.type("q", "First"); selenium.click("btnG"); }
@Test public void test_second() { selenium.open("/"); selenium.type("q", "second"); selenium.click("btnG"); }
}
Now the above script executes on the node of the selenium grid2 and I need to extract the logs of the script execution on the node.
We tried to use Logger to extract the logs of the nodes but what we get are the logs of the hub which is undesirable. Please suggest a way out for extracting the logs of the script executing on the node of the selenium grid. A sample code snippet will be really helpful
We referred this SO post -: How to get Test Activity Logs from Selenium Grid 2 programatically?
but in the above post the method requires a session-id attribute but we aren't able to retrieve the session id as we have made it a standalone system.
Thanks in advance
Thanks in advance
On Tuesday, 3 July 2012 23:02:11 UTC+5:30, Mike Riley wrote:To what logs are you referring to? The ones produced by the server, or logs produced by your test code (like TestNG reports)?
Mike
On Tuesday, July 3, 2012 1:39:55 AM UTC-7, Coder wrote:I am trying to test scripts on the nodes of selenium grid2 but I am not able to get the logs of their execution, can anybody please help me with retrieving the logs of the remote controls in selenium grid.Thanks in advance
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/IkHFQtQ2a2sJ.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en-US.
To post to this group, send email to selenium-users@googlegroups.com.
To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/Z9C0fo-TgLwJ.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/P008YN4hCeYJ.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/s5XJ3m0DUd0J.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/ZsgSj3g1L8kJ.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/O88uxdLjNBYJ.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/kSkrALZSMK4J.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/52HcZUi7c4gJ.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/OCLL2GVpY18J.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/xH8gxqauwtIJ.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/IKpGV-HAobQJ.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/UCEqRMrVPTMJ.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.