本文整理汇总了Java中org.openqa.grid.common.SeleniumProtocol类的典型用法代码示例。如果您正苦于以下问题:Java SeleniumProtocol类的具体用法?Java SeleniumProtocol怎么用?Java SeleniumProtocol使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SeleniumProtocol类属于org.openqa.grid.common包,在下文中一共展示了SeleniumProtocol类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: tabBrowsers
import org.openqa.grid.common.SeleniumProtocol; //导入依赖的package包/类
private String tabBrowsers() {
StringBuilder builder = new StringBuilder();
builder.append("<div type='browsers' class='content_detail'>");
SlotsLines rcLines = new SlotsLines();
SlotsLines wdLines = new SlotsLines();
for (TestSlot slot : proxy.getTestSlots()) {
if (slot.getProtocol() == SeleniumProtocol.Selenium) {
rcLines.add(slot);
} else {
wdLines.add(slot);
}
}
if (rcLines.getLinesType().size() != 0) {
builder.append("<p class='protocol' >Remote Control (legacy)</p>");
builder.append(getLines(rcLines));
}
if (wdLines.getLinesType().size() != 0) {
builder.append("<p class='protocol' >WebDriver</p>");
builder.append(getLines(wdLines));
}
builder.append("</div>");
return builder.toString();
}
示例2: testRequestNodeExpiredState
import org.openqa.grid.common.SeleniumProtocol; //导入依赖的package包/类
@Test
// Tests that a node in the Expired state is not considered as a free resource
public void testRequestNodeExpiredState() throws IOException, ServletException{
String browser = "firefox";
String nodeId = "nodeId";
// Add a node that is not running to make sure its not included in the available calculation
AutomationDynamicNode node = new AutomationDynamicNode("testUuid",nodeId,null,null,new Date(),10);
node.updateStatus(AutomationDynamicNode.STATUS.EXPIRED);
AutomationContext.getContext().addNode(node);
ProxySet proxySet = new ProxySet(false);
MockRemoteProxy proxy = new MockRemoteProxy();
proxy.setCapabilityMatcher(new AutomationCapabilityMatcher());
Map<String,Object> config = new HashMap<String, Object>();
config.put(AutomationConstants.INSTANCE_ID, nodeId);
proxy.setConfig(config);
List<TestSlot> testSlots = new ArrayList<TestSlot>();
Map<String,Object> capabilities = new HashMap<String,Object>();
capabilities.put(CapabilityType.BROWSER_NAME,browser);
testSlots.add(new TestSlot(proxy, SeleniumProtocol.WebDriver, null, capabilities));
proxy.setTestSlots(testSlots);
proxySet.add(proxy);
AutomationContext.getContext().setTotalNodeCount(50);
AutomationRequestMatcher requestMatcher = new AutomationRequestMatcher();
int freeThreads = requestMatcher.getNumFreeThreadsForParameters(proxySet,new AutomationRunRequest(browser));
Assert.assertEquals("Thread count should be correct due to an expired node", 0, freeThreads);
}
示例3: testRequestNodeTerminatedNoInstanceId
import org.openqa.grid.common.SeleniumProtocol; //导入依赖的package包/类
@Test
// Tests that a node in the Terminated state without an instance id is still considered a valid resource
public void testRequestNodeTerminatedNoInstanceId() throws IOException, ServletException{
String browser = "firefox";
String nodeId = "nodeId";
// Add a node that is not running to make sure its not included in the available calculation
AutomationDynamicNode node = new AutomationDynamicNode("testUuid",nodeId,null,null,new Date(),10);
node.updateStatus(AutomationDynamicNode.STATUS.TERMINATED);
AutomationContext.getContext().addNode(node);
ProxySet proxySet = new ProxySet(false);
MockRemoteProxy proxy = new MockRemoteProxy();
proxy.setCapabilityMatcher(new AutomationCapabilityMatcher());
proxy.setMaxNumberOfConcurrentTestSessions(5);
Map<String,Object> config = new HashMap<>();
proxy.setConfig(config);
List<TestSlot> testSlots = new ArrayList<TestSlot>();
Map<String,Object> capabilities = new HashMap<String,Object>();
capabilities.put(CapabilityType.BROWSER_NAME,browser);
testSlots.add(new TestSlot(proxy, SeleniumProtocol.WebDriver, null, capabilities));
proxy.setTestSlots(testSlots);
proxySet.add(proxy);
AutomationContext.getContext().setTotalNodeCount(50);
AutomationRequestMatcher requestMatcher = new AutomationRequestMatcher();
int freeThreads = requestMatcher.getNumFreeThreadsForParameters(proxySet,new AutomationRunRequest(browser));
Assert.assertEquals("Node should be available since instance id was not on the node", 1, freeThreads);
}
示例4: testRequestMatchingBrowsers
import org.openqa.grid.common.SeleniumProtocol; //导入依赖的package包/类
@Test
// Happy path that browsers matching shows correct free node count
public void testRequestMatchingBrowsers() throws IOException, ServletException{
String browser = "firefox";
String nodeId = "nodeId";
// Add a node that is not running to make sure its not included in the available calculation
AutomationDynamicNode node = new AutomationDynamicNode("testUuid",nodeId,null,null,new Date(),50);
AutomationContext.getContext().addNode(node);
ProxySet proxySet = new ProxySet(false);
MockRemoteProxy proxy = new MockRemoteProxy();
proxy.setMaxNumberOfConcurrentTestSessions(50);
proxy.setCapabilityMatcher(new AutomationCapabilityMatcher());
Map<String,Object> config = new HashMap<String, Object>();
config.put(AutomationConstants.INSTANCE_ID,nodeId);
proxy.setConfig(config);
Map<String,Object> capabilities = new HashMap<String,Object>();
capabilities.put(CapabilityType.BROWSER_NAME,browser);
TestSlot testSlot = new TestSlot(proxy, SeleniumProtocol.WebDriver,null,capabilities);
proxy.setMultipleTestSlots(testSlot, 10);
proxySet.add(proxy);
AutomationContext.getContext().setTotalNodeCount(50);
int freeThreads = new AutomationRequestMatcher().getNumFreeThreadsForParameters(proxySet,new AutomationRunRequest(browser));
Assert.assertEquals("Thread count should be correct due to matching browser", 10, freeThreads);
}
示例5: testRequestNonMatchingBrowsers
import org.openqa.grid.common.SeleniumProtocol; //导入依赖的package包/类
@Test
// Test that non-matching browsers do not contribute to the free node count
public void testRequestNonMatchingBrowsers() throws IOException, ServletException{
String browser = "firefox";
String nodeId = "nodeId";
// Add a node that is not running to make sure its not included in the available calculation
AutomationDynamicNode node = new AutomationDynamicNode("testUuid",nodeId,null,null,new Date(),50);
AutomationContext.getContext().addNode(node);
ProxySet proxySet = new ProxySet(false);
MockRemoteProxy proxy = new MockRemoteProxy();
proxy.setMaxNumberOfConcurrentTestSessions(50);
proxy.setCapabilityMatcher(new AutomationCapabilityMatcher());
Map<String,Object> config = new HashMap<String, Object>();
config.put(AutomationConstants.INSTANCE_ID,nodeId);
proxy.setConfig(config);
Map<String,Object> capabilities = new HashMap<String,Object>();
capabilities.put(CapabilityType.BROWSER_NAME,"doesntMatch");
TestSlot testSlot = new TestSlot(proxy, SeleniumProtocol.WebDriver,null,capabilities);
proxy.setMultipleTestSlots(testSlot, 10);
proxySet.add(proxy);
AutomationContext.getContext().setTotalNodeCount(50);
int freeThreads = new AutomationRequestMatcher().getNumFreeThreadsForParameters(proxySet,new AutomationRunRequest(browser));
Assert.assertEquals("Thread count should be correct due to matching OS", 0, freeThreads);
}
示例6: testRequestAllTestSlotsIncluded
import org.openqa.grid.common.SeleniumProtocol; //导入依赖的package包/类
@Test
// Makes sure that all matching slots will be included to match
public void testRequestAllTestSlotsIncluded() throws IOException, ServletException{
String browser = "firefox";
String nodeId = "nodeId";
// Add a node that is not running to make sure its not included in the available calculation
AutomationDynamicNode node = new AutomationDynamicNode("testUuid",nodeId,null,null,new Date(),50);
AutomationContext.getContext().addNode(node);
ProxySet proxySet = new ProxySet(false);
MockRemoteProxy proxy = new MockRemoteProxy();
proxy.setMaxNumberOfConcurrentTestSessions(10);
proxy.setCapabilityMatcher(new AutomationCapabilityMatcher());
Map<String,Object> config = new HashMap<String, Object>();
config.put(AutomationConstants.INSTANCE_ID,nodeId);
proxy.setConfig(config);
Map<String,Object> capabilities = new HashMap<String,Object>();
capabilities.put(CapabilityType.BROWSER_NAME,"firefox");
TestSlot testSlot = new TestSlot(proxy, SeleniumProtocol.WebDriver,null,capabilities);
proxy.setMultipleTestSlots(testSlot, 10);
proxySet.add(proxy);
AutomationContext.getContext().setTotalNodeCount(50);
int freeThreads = new AutomationRequestMatcher().getNumFreeThreadsForParameters(proxySet,new AutomationRunRequest(browser));
Assert.assertEquals("There should be no matching threads since the node limit was reached",10,freeThreads);
}
示例7: testRequestAllTestSlotsIncludedGreaterNodeLimit
import org.openqa.grid.common.SeleniumProtocol; //导入依赖的package包/类
@Test
// Tests that the correct number of slots match even when the max session config on node is less than
// the slot number
public void testRequestAllTestSlotsIncludedGreaterNodeLimit() throws IOException, ServletException{
String browser = "firefox";
String nodeId = "nodeId";
// Add a node that is not running to make sure its not included in the available calculation
AutomationDynamicNode node = new AutomationDynamicNode("testUuid",nodeId,null,null,new Date(),50);
AutomationContext.getContext().addNode(node);
ProxySet proxySet = new ProxySet(false);
MockRemoteProxy proxy = new MockRemoteProxy();
proxy.setMaxNumberOfConcurrentTestSessions(15);
proxy.setCapabilityMatcher(new AutomationCapabilityMatcher());
Map<String,Object> config = new HashMap<String, Object>();
config.put(AutomationConstants.INSTANCE_ID,nodeId);
proxy.setConfig(config);
Map<String,Object> capabilities = new HashMap<String,Object>();
capabilities.put(CapabilityType.BROWSER_NAME,"firefox");
TestSlot testSlot = new TestSlot(proxy, SeleniumProtocol.WebDriver,null,capabilities);
proxy.setMultipleTestSlots(testSlot, 10);
proxySet.add(proxy);
AutomationContext.getContext().setTotalNodeCount(50);
int freeThreads = new AutomationRequestMatcher().getNumFreeThreadsForParameters(proxySet,new AutomationRunRequest(browser));
Assert.assertEquals("There should be no matching threads since the node limit was reached",10,freeThreads);
}
示例8: testRequestAllTestSlotsIncludedLessThanNodeLimit
import org.openqa.grid.common.SeleniumProtocol; //导入依赖的package包/类
@Test
// Tests that the correct number of slots match even when the max session config on node is greater than
// the slot number
public void testRequestAllTestSlotsIncludedLessThanNodeLimit() throws IOException, ServletException{
String browser = "firefox";
String nodeId = "nodeId";
// Add a node that is not running to make sure its not included in the available calculation
AutomationDynamicNode node = new AutomationDynamicNode("testUuid",nodeId,null,null,new Date(),50);
AutomationContext.getContext().addNode(node);
ProxySet proxySet = new ProxySet(false);
MockRemoteProxy proxy = new MockRemoteProxy();
proxy.setMaxNumberOfConcurrentTestSessions(5);
proxy.setCapabilityMatcher(new AutomationCapabilityMatcher());
Map<String,Object> config = new HashMap<String, Object>();
config.put(AutomationConstants.INSTANCE_ID,nodeId);
proxy.setConfig(config);
Map<String,Object> capabilities = new HashMap<String,Object>();
capabilities.put(CapabilityType.BROWSER_NAME,"firefox");
TestSlot testSlot = new TestSlot(proxy, SeleniumProtocol.WebDriver,null,capabilities);
proxy.setMultipleTestSlots(testSlot, 10);
proxySet.add(proxy);
AutomationContext.getContext().setTotalNodeCount(50);
int freeThreads = new AutomationRequestMatcher().getNumFreeThreadsForParameters(proxySet,new AutomationRunRequest(browser));
Assert.assertEquals("There should be no matching threads since the node limit was reached",5,freeThreads);
}
示例9: testRequestNewRunNotStarted
import org.openqa.grid.common.SeleniumProtocol; //导入依赖的package包/类
@Test
// Test to make sure an in progress counts against the free node count
public void testRequestNewRunNotStarted() throws IOException, ServletException{
String browser = "firefox";
String nodeId = "nodeId";
// Add a node that is not running to make sure its not included in the available calculation
AutomationDynamicNode node = new AutomationDynamicNode("testUuid",nodeId,null,null,new Date(),50);
AutomationContext.getContext().addNode(node);
String runId = "runId";
AutomationContext.getContext().addRun(new AutomationRunRequest(runId,10,"firefox"));
ProxySet proxySet = new ProxySet(false);
MockRemoteProxy proxy = new MockRemoteProxy();
proxy.setMaxNumberOfConcurrentTestSessions(50);
proxy.setCapabilityMatcher(new AutomationCapabilityMatcher());
Map<String,Object> config = new HashMap<String, Object>();
config.put(AutomationConstants.INSTANCE_ID, nodeId);
proxy.setConfig(config);
Map<String,Object> capabilities = new HashMap<String,Object>();
capabilities.put(CapabilityType.BROWSER_NAME,"firefox");
TestSlot testSlot = new TestSlot(proxy, SeleniumProtocol.WebDriver,null,capabilities);
proxy.setMultipleTestSlots(testSlot, 10);
proxySet.add(proxy);
AutomationContext.getContext().setTotalNodeCount(50);
int freeThreads = new AutomationRequestMatcher().getNumFreeThreadsForParameters(proxySet,new AutomationRunRequest(browser));
Assert.assertEquals("No nodes should be free since existing run hasn't started",0,freeThreads);
}
示例10: testNodesFreeNoUuid
import org.openqa.grid.common.SeleniumProtocol; //导入依赖的package包/类
@Test
// Tests that the correct node count is returned when tests don't have a UUID
public void testNodesFreeNoUuid() {
AutomationRunContext runContext = new AutomationRunContext();
runContext.setTotalNodeCount(10);
ProxySet proxySet = new ProxySet(false);
MockRemoteProxy proxy = new MockRemoteProxy();
proxy.setCapabilityMatcher(new AutomationCapabilityMatcher());
Map<String,Object> capabilities = new HashMap<>();
capabilities.put(CapabilityType.PLATFORM,"linux");
capabilities.put(CapabilityType.BROWSER_NAME,"chrome");
TestSlot testSlot = new TestSlot(proxy, SeleniumProtocol.WebDriver,null,capabilities);
testSlot.getNewSession(capabilities);
proxy.setMultipleTestSlots(testSlot,5);
proxySet.add(proxy);
int freeThreads = runContext.getTotalThreadsAvailable(proxySet);
Assert.assertEquals(5,freeThreads);
}
示例11: testNodesFreeWithUuid
import org.openqa.grid.common.SeleniumProtocol; //导入依赖的package包/类
@Test
// Tests that the correct node count is returned when tests don't have a UUID
public void testNodesFreeWithUuid() {
AutomationRunContext runContext = new AutomationRunContext();
runContext.setTotalNodeCount(10);
ProxySet proxySet = new ProxySet(false);
MockRemoteProxy proxy = new MockRemoteProxy();
proxy.setCapabilityMatcher(new AutomationCapabilityMatcher());
Map<String,Object> capabilities = new HashMap<>();
capabilities.put(CapabilityType.PLATFORM,"linux");
capabilities.put(CapabilityType.BROWSER_NAME,"chrome");
capabilities.put(AutomationConstants.UUID,"testUuid");
TestSlot testSlot = new TestSlot(proxy, SeleniumProtocol.WebDriver,null,capabilities);
testSlot.getNewSession(capabilities);
proxy.setMultipleTestSlots(testSlot,5);
proxySet.add(proxy);
int freeThreads = runContext.getTotalThreadsAvailable(proxySet);
Assert.assertEquals(5,freeThreads);
}
示例12: testNewRunIsCounted
import org.openqa.grid.common.SeleniumProtocol; //导入依赖的package包/类
@Test
// Tests that a new run is counted instead of tests in progress
public void testNewRunIsCounted() {
String uuid = "testUuid";
AutomationRunContext runContext = new AutomationRunContext();
runContext.setTotalNodeCount(10);
ProxySet proxySet = new ProxySet(false);
MockRemoteProxy proxy = new MockRemoteProxy();
proxy.setCapabilityMatcher(new AutomationCapabilityMatcher());
Map<String,Object> capabilities = new HashMap<>();
capabilities.put(CapabilityType.PLATFORM,"linux");
capabilities.put(CapabilityType.BROWSER_NAME,"chrome");
capabilities.put(AutomationConstants.UUID,uuid);
AutomationRunRequest request = new AutomationRunRequest(uuid,10,"chrome");
runContext.addRun(request);
TestSlot testSlot = new TestSlot(proxy, SeleniumProtocol.WebDriver,null,capabilities);
testSlot.getNewSession(capabilities);
proxy.setMultipleTestSlots(testSlot,5);
proxySet.add(proxy);
int freeThreads = runContext.getTotalThreadsAvailable(proxySet);
Assert.assertEquals(0,freeThreads);
}
示例13: testOldRunInProgress
import org.openqa.grid.common.SeleniumProtocol; //导入依赖的package包/类
@Test
// Tests that for an old run, the in progress tests are counted
public void testOldRunInProgress() {
String uuid = "testUuid";
AutomationRunContext runContext = new AutomationRunContext();
runContext.setTotalNodeCount(10);
ProxySet proxySet = new ProxySet(false);
MockRemoteProxy proxy = new MockRemoteProxy();
proxy.setCapabilityMatcher(new AutomationCapabilityMatcher());
Map<String,Object> capabilities = new HashMap<>();
capabilities.put(CapabilityType.PLATFORM,"linux");
capabilities.put(CapabilityType.BROWSER_NAME,"chrome");
capabilities.put(AutomationConstants.UUID,uuid);
AutomationRunRequest request = new AutomationRunRequest(uuid,10,"chrome","23","linux", AutomationUtils.modifyDate(new Date(),-5,Calendar.MINUTE));
runContext.addRun(request);
TestSlot testSlot = new TestSlot(proxy, SeleniumProtocol.WebDriver,null,capabilities);
testSlot.getNewSession(capabilities);
int inProgressTests = 5;
proxy.setMultipleTestSlots(testSlot,inProgressTests);
proxySet.add(proxy);
int freeThreads = runContext.getTotalThreadsAvailable(proxySet);
Assert.assertEquals("Free threads should reflect in progress test count",inProgressTests,freeThreads);
}
示例14: testRequestNodeTerminatedState
import org.openqa.grid.common.SeleniumProtocol; //导入依赖的package包/类
@Test
// Tests that a node in the Terminated state is not considered as a free resource
public void testRequestNodeTerminatedState() throws IOException, ServletException{
String browser = "firefox";
String nodeId = "nodeId";
// Add a node that is not running to make sure its not included in the available calculation
AutomationDynamicNode node = new AutomationDynamicNode("testUuid",nodeId,null,null,new Date(),10);
node.updateStatus(AutomationDynamicNode.STATUS.TERMINATED);
AutomationContext.getContext().addNode(node);
ProxySet proxySet = new ProxySet(false);
MockRemoteProxy proxy = new MockRemoteProxy();
proxy.setMaxNumberOfConcurrentTestSessions(5);
proxy.setCapabilityMatcher(new AutomationCapabilityMatcher());
Map<String,Object> config = new HashMap<>();
config.put(AutomationConstants.INSTANCE_ID, nodeId);
proxy.setConfig(config);
List<TestSlot> testSlots = new ArrayList<TestSlot>();
Map<String,Object> capabilities = new HashMap<String,Object>();
capabilities.put(CapabilityType.BROWSER_NAME,browser);
testSlots.add(new TestSlot(proxy, SeleniumProtocol.WebDriver, null, capabilities));
proxy.setTestSlots(testSlots);
proxySet.add(proxy);
AutomationContext.getContext().setTotalNodeCount(50);
AutomationRequestMatcher requestMatcher = new AutomationRequestMatcher();
int freeThreads = requestMatcher.getNumFreeThreadsForParameters(proxySet,new AutomationRunRequest(browser));
Assert.assertEquals("No threads should be available since the node was set to terminated", 0, freeThreads);
}
示例15: testRequestMatchingOs
import org.openqa.grid.common.SeleniumProtocol; //导入依赖的package包/类
@Test
// Tests that OS matching on a node works correctly
public void testRequestMatchingOs() throws IOException, ServletException {
String browser = "firefox";
String os = "linux";
String nodeId = "nodeId";
// Add a node that is not running to make sure its not included in the available calculation
AutomationDynamicNode node = new AutomationDynamicNode("testUuid",nodeId,null,null,new Date(),50);
AutomationContext.getContext().addNode(node);
ProxySet proxySet = new ProxySet(false);
MockRemoteProxy proxy = new MockRemoteProxy();
proxy.setMaxNumberOfConcurrentTestSessions(50);
proxy.setCapabilityMatcher(new AutomationCapabilityMatcher());
Map<String,Object> config = new HashMap<>();
config.put(AutomationConstants.INSTANCE_ID,nodeId);
proxy.setConfig(config);
Map<String,Object> capabilities = new HashMap<>();
capabilities.put(CapabilityType.BROWSER_NAME,"firefox");
capabilities.put(CapabilityType.PLATFORM,os);
TestSlot testSlot = new TestSlot(proxy, SeleniumProtocol.WebDriver,null,capabilities);
proxy.setMultipleTestSlots(testSlot, 10);
proxySet.add(proxy);
AutomationContext.getContext().setTotalNodeCount(50);
int freeThreads = new AutomationRequestMatcher().getNumFreeThreadsForParameters(proxySet,new AutomationRunRequest(null,null,browser,null,os));
Assert.assertEquals("Thread count should be correct due to matching OS", 10, freeThreads);
}