Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adfemg/jdev12.2 java8 #24

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions RichClientDemoTest/RichClientDemoTest-12-2.jpr
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,11 @@
<value n="isJDK" v="false"/>
</hash>
<hash>
<url n="id" path="../libs/Selenium Libs.library"/>
<value n="id" v="Adf-richclient-automation-12-2.jar"/>
<value n="isJDK" v="false"/>
</hash>
<hash>
<value n="id" v="Adf-richclient-automation-12-2.jar"/>
<url n="id" path="../../../../adf-selenium/libs/SeleniumLibs3.0.1.library"/>
<value n="isJDK" v="false"/>
</hash>
</list>
Expand All @@ -205,11 +205,11 @@
<value n="isJDK" v="false"/>
</hash>
<hash>
<url n="id" path="../libs/Selenium Libs.library"/>
<value n="id" v="Adf-richclient-automation-12-2.jar"/>
<value n="isJDK" v="false"/>
</hash>
<hash>
<value n="id" v="Adf-richclient-automation-12-2.jar"/>
<url n="id" path="../../../../adf-selenium/libs/SeleniumLibs3.0.1.library"/>
<value n="isJDK" v="false"/>
</hash>
</list>
Expand Down
2 changes: 1 addition & 1 deletion RichClientDemoTest/build-12-2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<path id="classpath">
<fileset dir="${basedir}/..">
<include name="libs/selenium-2.52.0/**/*.jar"/>
<include name="libs/selenium-3.0.1/**/*.jar"/>
<include name="libs/adf-richclient-automation-12-2.jar"/>
<include name="libs/junit*.jar"/>
</fileset>
Expand Down
8 changes: 4 additions & 4 deletions SeleniumTools/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>com.github.wvanderdeijl</groupId>
<artifactId>selenium-tools-12-2</artifactId>
<name>${project.groupId}:${project.artifactId}</name>
<version>1.0.0</version>
<version>3.0.0</version>
<description>Project for SeleniumTools-12-2</description>
<url>https://github.com/wvanderdeijl/adf-selenium</url>
<properties>
Expand Down Expand Up @@ -61,23 +61,23 @@
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-firefox-driver</artifactId>
<version>2.52.0</version>
<version>3.0.1</version>
<scope>compile</scope>
<classifier>javadoc</classifier>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-firefox-driver</artifactId>
<version>2.52.0</version>
<version>3.0.1</version>
<scope>compile</scope>
<classifier>sources</classifier>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.53.0</version>
<version>3.0.1</version>
<scope>compile</scope>
<type>jar</type>
</dependency>
Expand Down
34 changes: 32 additions & 2 deletions SeleniumTools/src/com/redheap/selenium/component/AdfComponent.java
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import com.redheap.selenium.errors.SubIdNotFoundException;

import java.io.IOException;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
Expand Down Expand Up @@ -30,15 +32,17 @@
import org.openqa.selenium.remote.RemoteWebElement;

public class AdfComponent /*extends BaseObject*/ {
private static final Logger logger = Logger.getLogger(AdfComponent.class.getName());

private final WebDriver driver;
private final String clientid;
private final WebElement element;
private long timeoutMillisecs = DFLT_WAIT_TIMEOUT_MSECS;

public static final long DFLT_WAIT_TIMEOUT_MSECS = 30000;
private static boolean timeoutRetrieved = false;
private static final long STD_WAIT_TIMEOUT_MSECS = 30000;
public static final long DFLT_WAIT_TIMEOUT_MSECS = getDefaultTimeout();

private static final Logger logger = Logger.getLogger(AdfComponent.class.getName());

private static final ServiceLoader<ComponentFactory> factories = ServiceLoader.load(ComponentFactory.class);
private static final Map<String, Class<? extends AdfComponent>> defaultComponents = new HashMap<>();
Expand Down Expand Up @@ -92,6 +96,32 @@ protected AdfComponent(WebDriver driver, String clientid) {
this.element = (elems != null && elems.size() == 1) ? elems.get(0) : null;
}

/**
* Gets the default timeout property value from the property default.wait.timeout
*
* @return timeout long
* @throws IOException
*/
public static long getDefaultTimeout() {
if (timeoutRetrieved) {
return DFLT_WAIT_TIMEOUT_MSECS;
} else {
long timeoutMillisecs = STD_WAIT_TIMEOUT_MSECS;

try {
timeoutMillisecs = Long.parseLong(System.getProperty("default.wait.timeout"));
}catch (Exception ex) {
logger.warning("Unable to read timeout, returning default");
return timeoutMillisecs;
} finally {
timeoutRetrieved = true;
}

return timeoutMillisecs;
}

}

public static <C extends AdfComponent> C forClientId(WebDriver driver, String clientid) {
// find component type
String type = (String) ((JavascriptExecutor) driver).executeScript(JS_GET_COMPONENT_TYPE, clientid);
Expand Down
19 changes: 19 additions & 0 deletions SeleniumTools/src/com/redheap/selenium/component/AdfListItem.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.redheap.selenium.component;

import org.openqa.selenium.WebDriver;

/**
* AdfListItem component class.
*/
public class AdfListItem extends AdfComponent {

/**
* Constructor.
* @param webDriver
* @param clientId
*/
public AdfListItem(WebDriver webDriver, String clientId) {
super(webDriver, clientId);
}

}
98 changes: 98 additions & 0 deletions SeleniumTools/src/com/redheap/selenium/component/AdfListView.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
package com.redheap.selenium.component;

import java.util.ArrayList;
import java.util.List;

import org.openqa.selenium.WebDriver;

/**
* AdfListView component class.
*/
public class AdfListView extends AdfComponent {

private static final String JS_SELECTED_ROWS =
JS_FIND_PEER +
"var keys=Object.keys(comp.getSelectedRowKeys()); var retval=[]; keys.forEach(function(key){retval.push(peer.getRowIndex(key))}); return retval;";

//Not great but comp.getRows() does not work.
//private static final String JS_GET_ROW_COUNT = JS_FIND_COMPONENT + "return comp.getRows();";
private static final String JS_GET_ROW_COUNT =
JS_FIND_COMPONENT + "var list=comp.getDescendantComponents(); var li=0; for(var i=0;i<list.length;i++ ){ " +
"if( list[i]._componentType == 'oracle.adf.RichListItem' ) li++; } return li;";

private static final String JS_FIND_RELATIVE_COMPONENT_CLIENTID_ROWKEY =
JS_FIND_COMPONENT +
"var child=comp.findComponent(arguments[1],arguments[2]); return child?child.getClientId():null";
private static final String JS_FIND_RELATIVE_COMPONENT_CLIENTID_ROWINDEX =
JS_FIND_PEER + "var idx=peer.getRowKey(arguments[2]); if (!idx){return null}" +
"var child=comp.findComponent(arguments[1],idx); return child?child.getClientId():null";

/**
* Constructor.
* @param webDriver
* @param clientId
*/
public AdfListView(WebDriver webDriver, String clientId) {
super(webDriver, clientId);
}

/**
* Return the indices of selected row.
* @return
*/
@SuppressWarnings("unchecked")
public List<Integer> getSelectedRows() {
return rowIndices((List<Long>) executeScript(JS_SELECTED_ROWS, getClientId()));
}

private List<Integer> rowIndices(List<Long> longs) {
List<Integer> retval = new ArrayList<Integer>(longs.size());
for (Long l : longs) {
retval.add(l.intValue());
}
return retval;
}

/**
* Get the rowcount of the AdfListView.
* @return
*/
public long getRowCount() {
return ((Number) executeScript(JS_GET_ROW_COUNT, getClientId())).longValue();
}

/**
* Find a given AdfComponent.
* @param <T>
* @param relativeClientId
* @param rowKey
* @return
*/
public <T extends AdfComponent> T findAdfComponent(String relativeClientId, String rowKey) {
String clientid =
(String) executeScript(JS_FIND_RELATIVE_COMPONENT_CLIENTID_ROWKEY, getClientId(), relativeClientId, rowKey);
if (clientid == null) {
return null;
}
return AdfComponent.forClientId(getDriver(), clientid);
}

/**
* Find the given AdfComponent.
* @param <T>
* @param relativeClientId
* @param rowIndex
* @return
*/
public <T extends AdfComponent> T findAdfComponent(String relativeClientId, int rowIndex) {
String clientid =
(String) executeScript(JS_FIND_RELATIVE_COMPONENT_CLIENTID_ROWINDEX, getClientId(), relativeClientId,
rowIndex);
if (clientid == null) {
return null;
}
T retval = AdfComponent.forClientId(getDriver(), clientid);
retval.scrollIntoView();
return retval;
}
}
45 changes: 45 additions & 0 deletions SeleniumTools/src/com/redheap/selenium/component/AdfPanelBox.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.redheap.selenium.component;

import org.openqa.selenium.WebDriver;

/**
* ADF Selenium representation of a {@code panelBox} component.
*/
public class AdfPanelBox extends AdfComponent {
// see javascript AdfDhtmlShowDetailItemPeer.prototype.GetSubIdDomElement
// see http://jdevadf.oracle.com/adf-richclient-demo/docs/js-subids.html
private static final String SUBID_DISCLOSE_LINK = "disclosure_icon";

/**
* Constructort, passthrough voor {@link AdfComponent} constructor.
* @param webDriver
* @param string
*/
public AdfPanelBox(final WebDriver webDriver, final String string) {
super(webDriver, string);
}

/**
* Getter voor attribuut {@code text}.
* @return value of attribute {@code text}, the title.
*/
public String getText() {
return (String) getProperty("text");
}

/**
* Override the standard click method.
*/
@Override
public void click() {
clickDiscloseLink();
}

/**
* Click open the showdetail component using the component sub id disclosure_icon.
*/
public void clickDiscloseLink() {
findSubIdElement(SUBID_DISCLOSE_LINK).click();
waitForPpr();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.redheap.selenium.component;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

public class AdfPanelCollection extends AdfComponent {

private static final String SUBID_expandAll = "viewMenu_expandAll"; //
private static final String SUBID_collapseAll = "viewMenu_collapseAll";
private static final String SUBID_viewMenu = "viewMenu"; //


public AdfPanelCollection(WebDriver webDriver, String string) {
super(webDriver, string);
}

public void clickExpandAll() {
WebElement viewmenu = findViewMenu();
viewmenu.click();
waitForPpr();

WebElement expandElement = findExpandAllElement();
expandElement.click();
waitForPpr();
}

public void clickCollapseAll() {
WebElement viewmenu = findViewMenu();
viewmenu.click();
waitForPpr();

WebElement collapseElement = findCollapseAllElement();
collapseElement.click();
waitForPpr();
}

protected WebElement findExpandAllElement() {
return findSubIdElement(SUBID_expandAll);
}

protected WebElement findViewMenu() {
return findSubIdElement(SUBID_viewMenu);
}

protected WebElement findCollapseAllElement() {
return findSubIdElement(SUBID_collapseAll);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.redheap.selenium.component;

import org.openqa.selenium.WebDriver;

/**
* ADF Selenium representation of a {@code AdfPanelStretchLayout} component.
*/
public class AdfPanelStretchLayout extends AdfComponent {
/**
* Default constructor.
* @param webDriver
* @param string
*/
public AdfPanelStretchLayout(WebDriver webDriver, String string) {
super(webDriver, string);
}
}
Loading