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..d1e082e 100644 --- a/java/pom.xml +++ b/java/pom.xml @@ -4,26 +4,33 @@ 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 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 - com.github.2gis.winium - winium-elements-desktop - 0.1.0-1 + + UTF-8 + @@ -36,20 +43,13 @@ org.seleniumhq.selenium selenium-java - 2.47.1 + 2.48.2 - junit - junit - 4.12 - test - - - org.mockito - mockito-core - 2.0.31-beta - test + com.github.2gis.winium + winium-webdriver + 0.1.0-1 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/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")); - } -} 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