From 2d6ecbb6b1c0542af5c53f1cdfd6ff8fb85c9b1f Mon Sep 17 00:00:00 2001 From: zebraxxl Date: Sun, 8 Nov 2015 02:39:50 +0300 Subject: [PATCH 1/5] Selenium version update and WiniumDriver move --- java/CHANGELOG.md | 5 ++ java/README.md | 9 +-- java/pom.xml | 21 +++++-- .../winium/elements/desktop/WiniumDriver.java | 53 ---------------- .../winium/elements/desktop/MockedDriver.java | 30 ---------- .../winium/elements/desktop/Responses.java | 27 --------- .../elements/desktop/TestsComboBox.java | 45 -------------- .../elements/desktop/TestsDataGrid.java | 60 ------------------- .../winium/elements/desktop/TestsListBox.java | 29 --------- .../winium/elements/desktop/TestsMenu.java | 45 -------------- 10 files changed, 24 insertions(+), 300 deletions(-) delete mode 100644 java/src/main/java/winium/elements/desktop/WiniumDriver.java delete mode 100644 java/src/test/java/winium/elements/desktop/MockedDriver.java delete mode 100644 java/src/test/java/winium/elements/desktop/Responses.java delete mode 100644 java/src/test/java/winium/elements/desktop/TestsComboBox.java delete mode 100644 java/src/test/java/winium/elements/desktop/TestsDataGrid.java delete mode 100644 java/src/test/java/winium/elements/desktop/TestsListBox.java delete mode 100644 java/src/test/java/winium/elements/desktop/TestsMenu.java diff --git a/java/CHANGELOG.md b/java/CHANGELOG.md index 359e881..dcc399b 100644 --- a/java/CHANGELOG.md +++ b/java/CHANGELOG.md @@ -1,6 +1,11 @@ # Change Log +## v0.2.0-1 + +- added Winium.WebDriver as dependence (WiniumDriver moved to it) +- selenium web driver version updated to 2.48.2 + ## v0.1.0-1 - combobox (collapse, expand, is expanded, find selected item, scroll to item) diff --git a/java/README.md b/java/README.md index 7a9e31e..f23e366 100644 --- a/java/README.md +++ b/java/README.md @@ -18,16 +18,11 @@ With the help of Winium.Elements you could simplify interaction with such comple com.github.2gis.winium winium-elements-desktop - 0.1.0-1 + 0.2.0-1 ``` -2. Use WiniumDriver instead of RemoteWebDriver. - - ```java - WiniumDriver driver = new WiniumDriver("http://localhost:9999", desiredCapabilities); - ``` -3. Find element and convert it to [ElementType] using WebElementExtensions.to[ElementType] method. +2. Find element and convert it to [ElementType] using WebElementExtensions.to[ElementType] method. ```java WebElement element = driver.findElementById("data_grid"); diff --git a/java/pom.xml b/java/pom.xml index c4f86b7..39da705 100644 --- a/java/pom.xml +++ b/java/pom.xml @@ -9,21 +9,28 @@ With the help of Winium.Elements you could simplify interaction with such complex elements like DataGrid, ComboBox, Menu and etc. - + + Mozilla Public License, version 2.0 + https://www.mozilla.org/en-US/MPL/2.0/ + https://github.com/2gis/Winium.Elements/ - Artem + Artem Pryanichnikov https://github.com/zebraxxl + + UTF-8 + + com.github.2gis.winium winium-elements-desktop - 0.1.0-1 + 0.2.0-1 @@ -36,7 +43,13 @@ org.seleniumhq.selenium selenium-java - 2.47.1 + 2.48.2 + + + + com.github.2gis.winium + winium-web-driver + 0.1.0-1 diff --git a/java/src/main/java/winium/elements/desktop/WiniumDriver.java b/java/src/main/java/winium/elements/desktop/WiniumDriver.java deleted file mode 100644 index 6517ead..0000000 --- a/java/src/main/java/winium/elements/desktop/WiniumDriver.java +++ /dev/null @@ -1,53 +0,0 @@ -package winium.elements.desktop; - -import org.openqa.selenium.Capabilities; -import org.openqa.selenium.remote.CommandInfo; -import org.openqa.selenium.remote.HttpCommandExecutor; -import org.openqa.selenium.remote.RemoteWebDriver; -import org.openqa.selenium.remote.http.HttpMethod; - -import java.net.MalformedURLException; -import java.net.URL; -import java.util.HashMap; - -public class WiniumDriver extends RemoteWebDriver { - private static HashMap commands; - - static { - commands = new HashMap(); - - commands.put(ComboBox.IS_COMBO_BOX_EXPANDED, - new CommandInfo("/session/:sessionId/element/:id/combobox/expanded", HttpMethod.POST)); - commands.put(ComboBox.EXPAND_COMBO_BOX, - new CommandInfo("/session/:sessionId/element/:id/combobox/expand", HttpMethod.POST)); - commands.put(ComboBox.COLLAPSE_COMBO_BOX, - new CommandInfo("/session/:sessionId/element/:id/combobox/collapse", HttpMethod.POST)); - commands.put(ComboBox.FIND_COMBO_BOX_SELECTED_ITEM, - new CommandInfo("/session/:sessionId/element/:id/combobox/items/selected", HttpMethod.POST)); - commands.put(ComboBox.SCROLL_TO_COMBO_BOX_ITEM, - new CommandInfo("/session/:sessionId/element/:id/combobox/scroll", HttpMethod.POST)); - - commands.put(DataGrid.FIND_DATA_GRID_CELL, - new CommandInfo("/session/:sessionId/element/:id/datagrid/cell/:row/:column", HttpMethod.POST)); - commands.put(DataGrid.GET_DATA_GRID_COLUMN_COUNT, - new CommandInfo("/session/:sessionId/element/:id/datagrid/column/count", HttpMethod.POST)); - commands.put(DataGrid.GET_DATA_GRID_ROW_COUNT, - new CommandInfo("/session/:sessionId/element/:id/datagrid/row/count", HttpMethod.POST)); - commands.put(DataGrid.SCROLL_TO_DATA_GRID_CELL, - new CommandInfo("/session/:sessionId/element/:id/datagrid/scroll/:row/:column", HttpMethod.POST)); - commands.put(DataGrid.SELECT_DATA_GRID_CELL, - new CommandInfo("/session/:sessionId/element/:id/datagrid/select/:row/:column", HttpMethod.POST)); - - commands.put(ListBox.SCROLL_TO_LIST_BOX_ITEM, - new CommandInfo("/session/:sessionId/element/:id/listbox/scroll", HttpMethod.POST)); - - commands.put(Menu.FIND_MENU_ITEM, - new CommandInfo("/session/:sessionId/element/:id/menu/item/:path", HttpMethod.POST)); - commands.put(Menu.SELECT_MENU_ITEM, - new CommandInfo("/session/:sessionId/element/:id/menu/select/:path", HttpMethod.POST)); - } - - public WiniumDriver(String url, Capabilities desiredCapabilities) throws MalformedURLException { - super(new HttpCommandExecutor(commands, new URL(url)), desiredCapabilities); - } -} diff --git a/java/src/test/java/winium/elements/desktop/MockedDriver.java b/java/src/test/java/winium/elements/desktop/MockedDriver.java deleted file mode 100644 index d878c7a..0000000 --- a/java/src/test/java/winium/elements/desktop/MockedDriver.java +++ /dev/null @@ -1,30 +0,0 @@ -package winium.elements.desktop; - -import org.openqa.selenium.Capabilities; -import org.openqa.selenium.remote.Response; -import org.openqa.selenium.remote.SessionId; - -import java.net.MalformedURLException; -import java.util.Map; - -import static org.mockito.Mockito.*; - -public class MockedDriver extends WiniumDriver { - public MockedDriver(String url, Capabilities desiredCapabilities) throws MalformedURLException { - super(url, desiredCapabilities); - } - - @Override - public Response execute(String driverCommand, Map parameters) { - return super.execute(driverCommand, parameters); - } - - public static MockedDriver getDriverMocked() { - MockedDriver driver = mock(MockedDriver.class); - - when(driver.execute(eq("newSession"), anyMapOf(String.class, Object.class))) - .thenReturn(new Response(new SessionId("AvesomeSession"))); - - return driver; - } -} diff --git a/java/src/test/java/winium/elements/desktop/Responses.java b/java/src/test/java/winium/elements/desktop/Responses.java deleted file mode 100644 index 922944c..0000000 --- a/java/src/test/java/winium/elements/desktop/Responses.java +++ /dev/null @@ -1,27 +0,0 @@ -package winium.elements.desktop; - -import org.openqa.selenium.remote.RemoteWebElement; -import org.openqa.selenium.remote.Response; -import static org.mockito.Mockito.*; - -public class Responses { - private Responses() { } - - public static Response getTrueResponse() { - Response result = new Response(); - result.setValue(true); - return result; - } - - public static Response getIntResponse(int value) { - Response result = new Response(); - result.setValue(value); - return result; - } - - public static Response getWebElementResponse() { - Response response = mock(Response.class); - when(response.getValue()).thenReturn(mock(RemoteWebElement.class)); - return response; - } -} diff --git a/java/src/test/java/winium/elements/desktop/TestsComboBox.java b/java/src/test/java/winium/elements/desktop/TestsComboBox.java deleted file mode 100644 index 591b18d..0000000 --- a/java/src/test/java/winium/elements/desktop/TestsComboBox.java +++ /dev/null @@ -1,45 +0,0 @@ -package winium.elements.desktop; - -import org.junit.Assert; -import org.junit.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.remote.RemoteWebElement; -import org.openqa.selenium.remote.Response; -import winium.elements.desktop.extensions.WebElementExtensions; - -import static org.mockito.Mockito.*; - -public class TestsComboBox { - @Test - public void testIsComboBoxExpanded() { - MockedDriver mockedDriver = MockedDriver.getDriverMocked(); - - when(mockedDriver.execute(eq("isComboBoxExpanded"), anyMapOf(String.class, Object.class))) - .thenReturn(Responses.getTrueResponse()); - - RemoteWebElement webElement = mock(RemoteWebElement.class); - when(webElement.getWrappedDriver()).thenReturn(mockedDriver); - when(webElement.getId()).thenReturn("comboBoxElementId"); - - ComboBox comboBox = WebElementExtensions.toComboBox(webElement); - - Assert.assertTrue(comboBox.isExpanded()); - } - - @Test - public void testScrollToComboBoxItem() { - MockedDriver mockedDriver = MockedDriver.getDriverMocked(); - - Response webElementResponse = Responses.getWebElementResponse(); - when(mockedDriver.execute(eq("scrollToComboBoxItem"), anyMapOf(String.class, Object.class))) - .thenReturn(webElementResponse); - - RemoteWebElement webElement = mock(RemoteWebElement.class); - when(webElement.getWrappedDriver()).thenReturn(mockedDriver); - when(webElement.getId()).thenReturn("comboBoxElementId"); - - ComboBox comboBox = WebElementExtensions.toComboBox(webElement); - - Assert.assertNotNull(comboBox.scrollTo(By.id("comboBoxItemElementId"))); - } -} diff --git a/java/src/test/java/winium/elements/desktop/TestsDataGrid.java b/java/src/test/java/winium/elements/desktop/TestsDataGrid.java deleted file mode 100644 index c0ae5d4..0000000 --- a/java/src/test/java/winium/elements/desktop/TestsDataGrid.java +++ /dev/null @@ -1,60 +0,0 @@ -package winium.elements.desktop; - -import org.junit.Assert; -import org.junit.Test; -import org.openqa.selenium.remote.RemoteWebElement; -import org.openqa.selenium.remote.Response; -import winium.elements.desktop.extensions.WebElementExtensions; - -import static org.mockito.Mockito.*; - -public class TestsDataGrid { - @Test - public void testFindDataGridCell() { - MockedDriver mockedDriver = MockedDriver.getDriverMocked(); - - Response webElementResponse = Responses.getWebElementResponse(); - when(mockedDriver.execute(eq("findDataGridCell"), anyMapOf(String.class, Object.class))) - .thenReturn(webElementResponse); - - RemoteWebElement webElement = mock(RemoteWebElement.class); - when(webElement.getWrappedDriver()).thenReturn(mockedDriver); - when(webElement.getId()).thenReturn("dGridElementId"); - - DataGrid dataGrid = WebElementExtensions.toDataGrid(webElement); - - Assert.assertNotNull(dataGrid.find(1, 1)); - } - - @Test - public void testGetDataGridColumnCount() { - MockedDriver mockedDriver = MockedDriver.getDriverMocked(); - - when(mockedDriver.execute(eq("getDataGridColumnCount"), anyMapOf(String.class, Object.class))) - .thenReturn(Responses.getIntResponse(2)); - - RemoteWebElement webElement = mock(RemoteWebElement.class); - when(webElement.getWrappedDriver()).thenReturn(mockedDriver); - when(webElement.getId()).thenReturn("dGridElementId"); - - DataGrid dataGrid = WebElementExtensions.toDataGrid(webElement); - - Assert.assertEquals(dataGrid.getColumnCount(), 2); - } - - @Test - public void testGetDataGridRowCount() { - MockedDriver mockedDriver = MockedDriver.getDriverMocked(); - - when(mockedDriver.execute(eq("getDataGridRowCount"), anyMapOf(String.class, Object.class))) - .thenReturn(Responses.getIntResponse(5)); - - RemoteWebElement webElement = mock(RemoteWebElement.class); - when(webElement.getWrappedDriver()).thenReturn(mockedDriver); - when(webElement.getId()).thenReturn("dGridElementId"); - - DataGrid dataGrid = WebElementExtensions.toDataGrid(webElement); - - Assert.assertEquals(dataGrid.getRowCount(), 5); - } -} diff --git a/java/src/test/java/winium/elements/desktop/TestsListBox.java b/java/src/test/java/winium/elements/desktop/TestsListBox.java deleted file mode 100644 index fe26a1f..0000000 --- a/java/src/test/java/winium/elements/desktop/TestsListBox.java +++ /dev/null @@ -1,29 +0,0 @@ -package winium.elements.desktop; - -import org.junit.Assert; -import org.junit.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.remote.RemoteWebElement; -import org.openqa.selenium.remote.Response; -import winium.elements.desktop.extensions.WebElementExtensions; - -import static org.mockito.Mockito.*; - -public class TestsListBox { - @Test - public void testScrollToListBoxItem() { - MockedDriver mockedDriver = MockedDriver.getDriverMocked(); - - Response webElementResponse = Responses.getWebElementResponse(); - when(mockedDriver.execute(eq("scrollToListBoxItem"), anyMapOf(String.class, Object.class))) - .thenReturn(webElementResponse); - - RemoteWebElement webElement = mock(RemoteWebElement.class); - when(webElement.getWrappedDriver()).thenReturn(mockedDriver); - when(webElement.getId()).thenReturn("listBoxElementId"); - - ListBox listBox = WebElementExtensions.toListBox(webElement); - - Assert.assertNotNull(listBox.scrollTo(By.id("listBoxItemElementId"))); - } -} diff --git a/java/src/test/java/winium/elements/desktop/TestsMenu.java b/java/src/test/java/winium/elements/desktop/TestsMenu.java deleted file mode 100644 index 370db23..0000000 --- a/java/src/test/java/winium/elements/desktop/TestsMenu.java +++ /dev/null @@ -1,45 +0,0 @@ -package winium.elements.desktop; - -import org.junit.Assert; -import org.junit.Test; -import org.openqa.selenium.remote.RemoteWebElement; -import org.openqa.selenium.remote.Response; -import winium.elements.desktop.extensions.WebElementExtensions; - -import static org.mockito.Mockito.*; - -public class TestsMenu { - @Test - public void testGetMenuItem() { - MockedDriver mockedDriver = MockedDriver.getDriverMocked(); - - Response webElementResponse = Responses.getWebElementResponse(); - when(mockedDriver.execute(eq("findMenuItem"), anyMapOf(String.class, Object.class))) - .thenReturn(webElementResponse); - - RemoteWebElement webElement = mock(RemoteWebElement.class); - when(webElement.getWrappedDriver()).thenReturn(mockedDriver); - when(webElement.getId()).thenReturn("menutId"); - - Menu menu = WebElementExtensions.toMenu(webElement); - - Assert.assertNotNull(menu.findItem("Level1$Level2")); - } - - @Test - public void testSelectMenuItem() { - MockedDriver mockedDriver = MockedDriver.getDriverMocked(); - - Response webElementResponse = Responses.getWebElementResponse(); - when(mockedDriver.execute(eq("selectMenuItem"), anyMapOf(String.class, Object.class))) - .thenReturn(webElementResponse); - - RemoteWebElement webElement = mock(RemoteWebElement.class); - when(webElement.getWrappedDriver()).thenReturn(mockedDriver); - when(webElement.getId()).thenReturn("menutId"); - - Menu menu = WebElementExtensions.toMenu(webElement); - - Assert.assertNotNull(menu.selectItem("Level1$Level2")); - } -} From f89b1b652065f2099a9fc3ba7284cdaddb81fbb4 Mon Sep 17 00:00:00 2001 From: zebraxxl Date: Sun, 8 Nov 2015 02:55:09 +0300 Subject: [PATCH 2/5] Removed unused dependencies --- java/pom.xml | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/java/pom.xml b/java/pom.xml index 39da705..2795daf 100644 --- a/java/pom.xml +++ b/java/pom.xml @@ -51,19 +51,6 @@ winium-web-driver 0.1.0-1 - - - junit - junit - 4.12 - test - - - org.mockito - mockito-core - 2.0.31-beta - test - From 6fa37a9c24190e218b819a9413d5dfc43bb3e7a2 Mon Sep 17 00:00:00 2001 From: zebraxxl Date: Tue, 10 Nov 2015 23:40:48 +0300 Subject: [PATCH 3/5] Winium WebDriver dependency fix --- java/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/pom.xml b/java/pom.xml index 2795daf..60a8601 100644 --- a/java/pom.xml +++ b/java/pom.xml @@ -48,7 +48,7 @@ com.github.2gis.winium - winium-web-driver + winium-webdriver 0.1.0-1 From c0c0195ceaeb59d6c490632e7d7fb2aeae38348c Mon Sep 17 00:00:00 2001 From: Golovin Gleb Date: Thu, 12 Nov 2015 10:47:08 +0600 Subject: [PATCH 4/5] Update ci scripts Remove work around tests --- java/scripts/ci.ps1 | 6 +++--- scripts/ci.ps1 | 2 -- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/java/scripts/ci.ps1 b/java/scripts/ci.ps1 index 9e88c11..3bd4021 100644 --- a/java/scripts/ci.ps1 +++ b/java/scripts/ci.ps1 @@ -15,10 +15,10 @@ else $projectDir = Join-Path $PSScriptRoot "../" -# Compile & Test -& $mvnPath -f $projectDir test +# Compile +& $mvnPath -f $projectDir compile if ($LASTEXITCODE -ne 0) { - Write-Output "Compile or test failed. See output" + Write-Output "Compile failed. See output" Exit $LASTEXITCODE } diff --git a/scripts/ci.ps1 b/scripts/ci.ps1 index e2e9409..d8392bf 100644 --- a/scripts/ci.ps1 +++ b/scripts/ci.ps1 @@ -21,5 +21,3 @@ if ($LASTEXITCODE -ne 0) Write-Output "Java build failed. See console output" Exit $LASTEXITCODE } - -Copy-Item ..\target\surefire-reports\*.xml -Destination $root From c35650e827e969c3fa3262eb595bf004a6811c43 Mon Sep 17 00:00:00 2001 From: Golovin Gleb Date: Thu, 12 Nov 2015 10:55:07 +0600 Subject: [PATCH 5/5] Update java project pom file Reorder tag (as in winium-webdriver project) --- java/pom.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/java/pom.xml b/java/pom.xml index 60a8601..d1e082e 100644 --- a/java/pom.xml +++ b/java/pom.xml @@ -4,6 +4,10 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 + com.github.2gis.winium + winium-elements-desktop + 0.2.0-1 + Winium.Elements.Desktop https://github.com/2gis/Winium.Elements/tree/master/java With the help of Winium.Elements you could simplify interaction @@ -28,10 +32,6 @@ UTF-8 - com.github.2gis.winium - winium-elements-desktop - 0.2.0-1 - ossrh