• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java TestSession类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.openqa.grid.internal.TestSession的典型用法代码示例。如果您正苦于以下问题:Java TestSession类的具体用法?Java TestSession怎么用?Java TestSession使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



TestSession类属于org.openqa.grid.internal包,在下文中一共展示了TestSession类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getNewSession

import org.openqa.grid.internal.TestSession; //导入依赖的package包/类
@Override
public TestSession getNewSession(Map<String, Object> requestedCapability) {

    if (counter.get() > ConfigReader.getInstance().getMaxSession()) {
        LOG.info("Waiting for remote nodes to be available");
        return null;
    }

    if (LOG.isLoggable(Level.FINE)) {
        LOG.fine(String.format("Trying to create a new session on node %s", this));
    }

    // any slot left for the given app ?
    for (TestSlot testslot : getTestSlots()) {
        TestSession session = testslot.getNewSession(requestedCapability);
        if (session != null) {
            return session;
        }
    }
    return null;
}
 
开发者ID:RationaleEmotions,项目名称:just-ask,代码行数:22,代码来源:GhostProxy.java


示例2: beforeCommand

import org.openqa.grid.internal.TestSession; //导入依赖的package包/类
@Override
public void beforeCommand(TestSession session, HttpServletRequest request, HttpServletResponse response) {
    RequestType type = identifyRequestType(request);
    if (type == START_SESSION) {
        try {
            if (processTestSession(session)) {
                startServerForTestSession(session);
            } else {
                String msg = "Missing target mapping. Available mappings are " +
                    ConfigReader.getInstance().getMapping();
                throw new IllegalStateException(msg);
            }
        } catch (Exception e) {
            getRegistry().terminate(session, SessionTerminationReason.CREATIONFAILED);
            LOG.severe("Failed creating a session. Root cause :" + e.getMessage());
            throw e;
        }
    }
    super.beforeCommand(session, request, response);
}
 
开发者ID:RationaleEmotions,项目名称:just-ask,代码行数:21,代码来源:GhostProxy.java


示例3: beforeSession

import org.openqa.grid.internal.TestSession; //导入依赖的package包/类
@Override
public void beforeSession(TestSession session) {
    super.beforeSession(session);
    HttpPost r = new HttpPost(serviceUrl + "?command=start");
    try {
        HttpResponse response = client.execute(remoteHost, r);
        if(response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
            log.warning("Could not start video reporting: " + EntityUtils.toString(response.getEntity()));
            return;
        }
        log.info("Started recording for new session on node: " + getId());

    } catch (Exception e) {
        log.warning("Could not start video reporting due to exception: " + e.getMessage());
        e.printStackTrace();
    }
    finally {
        r.releaseConnection();
    }
}
 
开发者ID:pojosontheweb,项目名称:selenium-utils,代码行数:21,代码来源:NodeProxy.java


示例4: afterSession

import org.openqa.grid.internal.TestSession; //导入依赖的package包/类
@Override
public void afterSession(TestSession session) {
    super.afterSession(session);
    HttpPost r = new HttpPost(serviceUrl + "?command=stop");
    try {
        HttpResponse response = client.execute(remoteHost, r);
        if(response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
            log.warning("Could not stop video reporting: " + EntityUtils.toString(response.getEntity()));
            return;
        }
        log.info("Stopped recording for new session on node: " + getId());

    } catch (Exception e) {
        log.warning("Could not stop video reporting due to exception: " + e.getMessage());
        e.printStackTrace();
    }
    finally {
        r.releaseConnection();
    }
}
 
开发者ID:pojosontheweb,项目名称:selenium-utils,代码行数:21,代码来源:NodeProxy.java


示例5: getNumInProgressTests

import org.openqa.grid.internal.TestSession; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public int getNumInProgressTests(ProxySet proxySet, AutomationRunRequest runRequest) {
    int inProgressTests = 0;
    for(RemoteProxy proxy : proxySet) {
        for(TestSlot testSlot : proxy.getTestSlots() ) {
            TestSession session = testSlot.getSession();
            if(session != null) {
                if(runRequest.matchesCapabilities(session.getRequestedCapabilities())) {
                    inProgressTests++;
                }
            }
        }
    }
    return inProgressTests;
}
 
开发者ID:RetailMeNot,项目名称:SeleniumGridScaler,代码行数:19,代码来源:AutomationRequestMatcher.java


示例6: afterCommand

import org.openqa.grid.internal.TestSession; //导入依赖的package包/类
@Override
public void afterCommand(TestSession session, HttpServletRequest request, HttpServletResponse response) {
    super.afterCommand(session, request, response);
    RequestType type = identifyRequestType(request);
    if (type == STOP_SESSION) {
        stopServerForTestSession(session);
        if (LOG.isLoggable(Level.INFO)) {
            LOG.info(String.format("Counter value after decrementing : %d", counter.decrementAndGet()));
        }
    }
}
 
开发者ID:RationaleEmotions,项目名称:just-ask,代码行数:12,代码来源:GhostProxy.java


示例7: startServerForTestSession

import org.openqa.grid.internal.TestSession; //导入依赖的package包/类
private void startServerForTestSession(TestSession session) {
    try {
        SpawnedServer server = SpawnedServer.spawnInstance(session);
        String key = "http://" + server.getHost() + ":" + server.getPort();
        URL url = new URL(key);
        servers.put(key, server);
        ((ProxiedTestSlot) session.getSlot()).setRemoteURL(url);
        if (LOG.isLoggable(Level.INFO)) {
            LOG.info(String.format("Forwarding session to :%s", session.getSlot().getRemoteURL()));
            LOG.info(String.format("Counter value after incrementing : %d", counter.incrementAndGet()));
        }
    } catch (Exception e) {
        throw new GridException(e.getMessage(), e);
    }
}
 
开发者ID:RationaleEmotions,项目名称:just-ask,代码行数:16,代码来源:GhostProxy.java


示例8: stopServerForTestSession

import org.openqa.grid.internal.TestSession; //导入依赖的package包/类
private void stopServerForTestSession(TestSession session) {
    URL url = session.getSlot().getRemoteURL();
    String key = String.format("%s://%s:%d", url.getProtocol(), url.getHost(), url.getPort());
    SpawnedServer localServer = servers.get(key);
    if (localServer != null) {
        localServer.shutdown();
        servers.remove(key);
    }
}
 
开发者ID:RationaleEmotions,项目名称:just-ask,代码行数:10,代码来源:GhostProxy.java


示例9: spawnInstance

import org.openqa.grid.internal.TestSession; //导入依赖的package包/类
public static SpawnedServer spawnInstance(TestSession session) throws Exception {
    SpawnedServer server = new SpawnedServer();
    AtomicInteger attempts = new AtomicInteger(0);
    String browser = (String) session.getRequestedCapabilities().get(CapabilityType.BROWSER_NAME);
    server.server = newInstance(browser);
    int port = server.server.startServer(session);

    do {
        TimeUnit.SECONDS.sleep(2);
    } while (!server.server.isServerRunning() && attempts.incrementAndGet() <= 5);
    if (LOG.isLoggable(Level.WARNING)) {
        LOG.warning(String.format("***Server started on [%d]****", port));
    }
    return server;
}
 
开发者ID:RationaleEmotions,项目名称:just-ask,代码行数:16,代码来源:SpawnedServer.java


示例10: startServer

import org.openqa.grid.internal.TestSession; //导入依赖的package包/类
@Override
public int startServer(TestSession session) throws ServerException {
    try {
        String browser = (String) session.getRequestedCapabilities().get(CapabilityType.BROWSER_NAME);
        String image = ConfigReader.getInstance().getMapping().get(browser).getTarget();
        containerInfo = DockerHelper.startContainerFor(image, isPrivileged(), getDeviceInfos());
        return containerInfo.getPort();
    } catch (DockerException | InterruptedException e) {
        throw new ServerException(e.getMessage(), e);
    }
}
 
开发者ID:RationaleEmotions,项目名称:just-ask,代码行数:12,代码来源:DockerBasedSeleniumServer.java


示例11: startServer

import org.openqa.grid.internal.TestSession; //导入依赖的package包/类
@Override
public int startServer(TestSession session) throws ServerException {
    port = PortProber.findFreePort();
    String[] args = getArgs(port);
    if (LOG.isLoggable(Level.INFO)) {
        LOG.info(String.format("Spawning a Selenium server using the arguments [%s]", Arrays.toString(args)));
    }
    ProcessBuilder pb = new ProcessBuilder(getArgs(port));
    try {
        this.process = pb.start();
        return port;
    } catch (Exception e) {
        throw new ServerException(e.getMessage(), e);
    }
}
 
开发者ID:RationaleEmotions,项目名称:just-ask,代码行数:16,代码来源:JvmBasedSeleniumServer.java


示例12: afterSession

import org.openqa.grid.internal.TestSession; //导入依赖的package包/类
public void afterSession(TestSession session) {
	if (this.hasRecordingStarted == true) {
		final String key = session.getInternalKey();
		HttpGetHelper helper = new HttpGetHelper(String.format(
				STOP_RECORDING_STRING, nodeUrl, key));
		try {
			helper.execute();
			hasRecordingStarted = false;
		} catch (Exception err) {
			System.out
					.println("Error occurred while stopping the recording "
							+ err.getMessage());
		}
	}
}
 
开发者ID:bharathkumar-gopalan,项目名称:grid-video-recorder,代码行数:16,代码来源:ScreenRecordingProxy.java


示例13: getRemoteHostForSession

import org.openqa.grid.internal.TestSession; //导入依赖的package包/类
public URL getRemoteHostForSession(String sessionId) {
    for (TestSession activeSession : registry.getActiveSessions()) {
        if (sessionId.equals(activeSession.getExternalKey().getKey())) {
            return activeSession.getSlot().getProxy().getRemoteHost();
        }
    }
    throw new IllegalArgumentException("Invalid sessionId. No active session is present for id:" + sessionId);
}
 
开发者ID:sterodium,项目名称:selenium-grid-extensions,代码行数:9,代码来源:SeleniumSessions.java


示例14: refreshTimeout

import org.openqa.grid.internal.TestSession; //导入依赖的package包/类
public void refreshTimeout(String sessionId) {
    for (TestSession activeSession : registry.getActiveSessions()) {
        if (sessionId.equals(activeSession.getExternalKey().getKey())) {
            refreshTimeout(activeSession);
        }
    }
}
 
开发者ID:sterodium,项目名称:selenium-grid-extensions,代码行数:8,代码来源:SeleniumSessions.java


示例15: setUp

import org.openqa.grid.internal.TestSession; //导入依赖的package包/类
@Before
public void setUp() {
    seleniumSessions = new SeleniumSessions(registry);
    activeSession = spy(new TestSession(null, null, Clock.systemDefaultZone()));

    when(activeSession.getExternalKey()).thenReturn(externalSessionKey);
    when(externalSessionKey.getKey()).thenReturn("sessionId");
    when(registry.getActiveSessions()).thenReturn(Sets.newHashSet(activeSession));
}
 
开发者ID:sterodium,项目名称:selenium-grid-extensions,代码行数:10,代码来源:SeleniumSessionsTest.java


示例16: doPost

import org.openqa.grid.internal.TestSession; //导入依赖的package包/类
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
		throws ServletException, IOException {
      SeleniumBasedRequest request = new OurRegistrationRequest(req, getRegistry());
      
      Map<String, Object> capabilities = request.extractDesiredCapability();
      String proxyId = (String)capabilities.get("proxyId");
      RemoteProxy proxyById = getRegistry().getProxyById(proxyId);
      
      if(proxyById == null) {
    	  resp.sendError(HttpStatus.SC_BAD_REQUEST, "Remote proxy not found: " + proxyId);
    	  return;
      }
      
      TestSession session = proxyById.getNewSession(capabilities);
      
      if(session == null) {
    	  log.warning("Test slot requested on proxy is unavailable. Proxy: " + proxyId + " capabilities: " + capabilities);
    	  resp.sendError(429, "Test Slot Unavailable");
    	  return;
      }
      
      session.forward(request, resp, true);
      	      
      if(session.getExternalKey() != null) {
    	  log.info("Created session successfully for proxy " + proxyId + " - cleaning up session");
    	  session.sendDeleteSessionRequest();
    	  
    	  // This will log a warning, about couldn't find a session
    	  getRegistry().terminate(session, SessionTerminationReason.CLIENT_STOPPED_SESSION);
      }
      else {
    	  log.warning("Could not create session on proxy for " + proxyId);
      }

}
 
开发者ID:aimmac23,项目名称:selenium-reliable-node-plugin,代码行数:37,代码来源:NodeTestingServlet.java


示例17: afterSession

import org.openqa.grid.internal.TestSession; //导入依赖的package包/类
@Override
public void afterSession(TestSession session) {
	super.afterSession(session);
	
	Map<String, Object> capabilities = session.getSlot().getCapabilities();

	if(session.getExternalKey() == null && workingCapabilities.contains(capabilities)) {
		// session creation failed on a slot we thought was working - we should do something about this
		System.out.println("Session creation failed, re-testing configuration: " + capabilities);
		setCapabilityAsBroken(capabilities);
		RemoteNodeTester.testRemoteNode(this, capabilities);
	}
}
 
开发者ID:aimmac23,项目名称:selenium-reliable-node-plugin,代码行数:14,代码来源:ReliableProxy.java


示例18: render

import org.openqa.grid.internal.TestSession; //导入依赖的package包/类
private JSONObject render(TestSlot slot) throws JSONException {
    JSONObject json = new JSONObject();
    json.put("capabilities", slot.getCapabilities());
    TestSession session = slot.getSession();

    if (session != null) {
        json.put("session", render(session));
        json.put("busy", true);
    } else {
        json.put("busy", false);
    }

    return json;
}
 
开发者ID:jabbrwcky,项目名称:selenium-api,代码行数:15,代码来源:WebProxyJsonRenderer.java


示例19: CommandReporter

import org.openqa.grid.internal.TestSession; //导入依赖的package包/类
public CommandReporter(String remoteHostName, InfluxDB influxdb, String database, TestSession session, ContentSnoopingRequest request, HttpServletResponse response, ReportType type) {
    super(remoteHostName, influxdb, database);
    this.type = type;
    this.request = request;
    this.session = session;
    this.response = response;
}
 
开发者ID:jabbrwcky,项目名称:selenium-api,代码行数:8,代码来源:CommandReporter.java


示例20: process

import org.openqa.grid.internal.TestSession; //导入依赖的package包/类
protected void process(HttpServletRequest request, HttpServletResponse response) throws IOException 
  {
response.setContentType("application/json");
   response.setCharacterEncoding("UTF-8");
   response.setStatus(HttpStatus.SC_NOT_FOUND);

String id = request.getParameter("session");
if(id != null)
{
	TestSession session = this.getRegistry().getExistingSession(ExternalSessionKey.fromString(id));
	if(session != null)
	{
		Map<String, Object> cap = session.getSlot().getCapabilities();
		if(cap.containsKey("udid"))
		{
			RemoteDevice device = new RemoteDevice(); 
			device.setName((String) cap.get("deviceName"));
			device.setOs((String) cap.get("platformName"));
			device.setOsVersion((String) cap.get("platformVersion"));
			device.setType((String) cap.get("deviceType"));
			device.setUdid((String) cap.get("udid"));
			
			STFDevice stfDevice = STF.getDevice(device.getUdid());
			if(stfDevice != null)
			{
				device.setRemoteURL((String) stfDevice.getRemoteConnectUrl());
			}
			
			response.setStatus(HttpStatus.SC_OK);
			response.getWriter().print(new ObjectMapper().writeValueAsString(device));
		    response.getWriter().close();
		}
	}
}
  }
 
开发者ID:qaprosoft,项目名称:carina,代码行数:36,代码来源:DeviceInfo.java



注:本文中的org.openqa.grid.internal.TestSession类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ASTWriter类代码示例发布时间:2022-05-22
下一篇:
Java ReplicaWaitingToBeRecovered类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap