Search in sources :

Example 1 with BrowserExtension

use of com.seleniumtests.browserfactory.BrowserExtension in project seleniumRobot by bhecquet.

the class TestBrowserExtension method testCreateExtensionFromOptions.

/**
 * Test standard case where extension and options are defined
 */
@Test(groups = "ut")
public void testCreateExtensionFromOptions() {
    Map<String, TestVariable> options = new HashMap<>();
    options.put("extension0.path", new TestVariable("extension0.path", "/home/test/ext.crx"));
    options.put("extension0.options", new TestVariable("extension0.options", "key1=value1;key2=value2"));
    List<BrowserExtension> extensions = BrowserExtension.getExtensions(options);
    Assert.assertEquals(extensions.size(), 1);
    Assert.assertEquals(extensions.get(0).getExtensionPath(), new File("/home/test/ext.crx"));
    Assert.assertEquals(extensions.get(0).getOptions().size(), 2);
    Assert.assertEquals(extensions.get(0).getOptions().get("key1"), "value1");
    Assert.assertEquals(extensions.get(0).getOptions().get("key2"), "value2");
}
Also used : HashMap(java.util.HashMap) BrowserExtension(com.seleniumtests.browserfactory.BrowserExtension) TestVariable(com.seleniumtests.core.TestVariable) File(java.io.File) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 2 with BrowserExtension

use of com.seleniumtests.browserfactory.BrowserExtension in project seleniumRobot by bhecquet.

the class TestBrowserExtension method testCreateExtensionWithoutOptions.

/**
 * Test when options do not define extension parameters
 */
@Test(groups = "ut")
public void testCreateExtensionWithoutOptions() {
    Map<String, TestVariable> options = new HashMap<>();
    options.put("extension0.path", new TestVariable("extension0.path", "/home/test/ext.crx"));
    List<BrowserExtension> extensions = BrowserExtension.getExtensions(options);
    Assert.assertEquals(extensions.size(), 1);
    Assert.assertEquals(extensions.get(0).getExtensionPath(), new File("/home/test/ext.crx"));
    Assert.assertEquals(extensions.get(0).getOptions().size(), 0);
}
Also used : HashMap(java.util.HashMap) BrowserExtension(com.seleniumtests.browserfactory.BrowserExtension) TestVariable(com.seleniumtests.core.TestVariable) File(java.io.File) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 3 with BrowserExtension

use of com.seleniumtests.browserfactory.BrowserExtension in project seleniumRobot by bhecquet.

the class TestBrowserExtension method testExtensionFromUrl.

@Test(groups = "ut")
public void testExtensionFromUrl() throws IOException {
    BrowserExtension extension = new BrowserExtension(String.format("http://%s:%d/test.html", localAddress, server.getServerHost().getPort()));
    Assert.assertEquals(extension.getExtensionPath().getParentFile(), File.createTempFile("file", ".tmp").getParentFile());
    Assert.assertEquals(FilenameUtils.getExtension(extension.getExtensionPath().getName()), "html");
}
Also used : BrowserExtension(com.seleniumtests.browserfactory.BrowserExtension) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Aggregations

GenericTest (com.seleniumtests.GenericTest)3 BrowserExtension (com.seleniumtests.browserfactory.BrowserExtension)3 Test (org.testng.annotations.Test)3 TestVariable (com.seleniumtests.core.TestVariable)2 File (java.io.File)2 HashMap (java.util.HashMap)2