Skip to content
This repository was archived by the owner on Apr 7, 2022. It is now read-only.

Commit 9748610

Browse files
committed
Clean unused methods.
Add some files to svn:ignore
1 parent 58786cc commit 9748610

2 files changed

Lines changed: 26 additions & 104 deletions

File tree

jwebunit-core/src/main/java/net/sourceforge/jwebunit/IJWebUnitDialog.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,6 @@ void beginAt(String aInitialURL, TestContext aTestContext)
3737
*/
3838
void gotoPage(String url) throws TestingEngineResponseException;
3939

40-
/**
41-
* Simulate user pressing "go back" button of the browser.
42-
*/
43-
void goBack();
44-
45-
/**
46-
* Simulate user pressing "refresh" button of the browser.
47-
*/
48-
void refresh();
49-
5040
/**
5141
* Enable or disable Javascript support
5242
*/

jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitDialog.java

Lines changed: 26 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -151,16 +151,6 @@ public void gotoPage(String initialURL)
151151
}
152152
}
153153

154-
public void goBack() {
155-
// TODO Implement goBack in HtmlUnitDialog
156-
throw new UnsupportedOperationException("goBack");
157-
}
158-
159-
public void refresh() {
160-
// TODO Implement refresh in HtmlUnitDialog
161-
throw new UnsupportedOperationException("refresh");
162-
}
163-
164154
/**
165155
* @see net.sourceforge.jwebunit.IJWebUnitDialog#setScriptingEnabled(boolean)
166156
*/
@@ -350,23 +340,6 @@ public void setTextField(String fieldName, String paramValue) {
350340
getForm().getInputByName(fieldName).setValueAttribute(paramValue);
351341
}
352342

353-
// /**
354-
// * Return a string array of select box option labels.
355-
// *
356-
// * @param selectName
357-
// * name of the select box.
358-
// */
359-
// public String[] getOptionsFor(String selectName) {
360-
// HtmlSelect sel = getForm().getSelectByName(selectName);
361-
// ArrayList result = new ArrayList();
362-
// List opts = sel.getOptions();
363-
// for (int i = 0; i < opts.size(); i++) {
364-
// HtmlOption opt = (HtmlOption) opts.get(i);
365-
// result.add(opt.asText());
366-
// }
367-
// return (String[]) result.toArray(new String[0]);
368-
// }
369-
370343
/**
371344
* Return a string array of select box option values.
372345
*
@@ -1042,19 +1015,6 @@ public void reset() {
10421015
getForm().reset();
10431016
}
10441017

1045-
/**
1046-
* Return true if a link is present in the current response containing the
1047-
* specified text (note that HttpUnit uses contains rather than an exact
1048-
* match - if this is a problem consider using ids on the links to uniquely
1049-
* identify them).
1050-
*
1051-
* @param linkText
1052-
* text to check for in links on the response.
1053-
*/
1054-
public boolean hasLinkWithText(String linkText) {
1055-
return getLinkWithText(linkText) != null;
1056-
}
1057-
10581018
/**
10591019
* Return true if a link is present in the current response containing the
10601020
* specified text (note that HttpUnit uses contains rather than an exact
@@ -1071,6 +1031,10 @@ public boolean hasLinkWithText(String linkText, int index) {
10711031
return getLinkWithText(linkText, index) != null;
10721032
}
10731033

1034+
public boolean hasLinkWithExactText(String linkText, int index) {
1035+
return getLinkWithExactText(linkText, index) != null;
1036+
}
1037+
10741038
public boolean hasLinkWithImage(String imageFileName, int index) {
10751039
return getLinkWithImage(imageFileName, index) != null;
10761040
}
@@ -1091,46 +1055,20 @@ public boolean hasLink(String anId) {
10911055
return true;
10921056
}
10931057

1094-
/*
1095-
* @see net.sourceforge.jwebunit.IJWebUnitDialog#isLinkPresentWithText(java.lang.String,
1096-
* int)
1097-
*/
1098-
public boolean hasLinkWithExactText(String linkText, int index) {
1099-
throw new UnsupportedOperationException("isLinkPresentWithText");
1100-
}
1101-
1102-
/*
1103-
* (non-Javadoc)
1104-
*
1105-
* @see net.sourceforge.jwebunit.IJWebUnitDialog#clickLinkWithExactText(java.lang.String)
1106-
*/
1107-
public void clickLinkWithExactText(String linkText) {
1108-
throw new UnsupportedOperationException("clickLinkWithExactText");
1058+
public void clickLinkWithText(String linkText, int index) {
1059+
HtmlAnchor link = getLinkWithText(linkText, index);
1060+
if (link == null)
1061+
throw new RuntimeException("No Link found for \"" + linkText
1062+
+ "\" with index " + index);
1063+
try {
1064+
link.click();
1065+
} catch (IOException e) {
1066+
throw new RuntimeException("Click failed");
1067+
}
11091068
}
11101069

1111-
/*
1112-
* (non-Javadoc)
1113-
*
1114-
* @see net.sourceforge.jwebunit.IJWebUnitDialog#clickLinkWithExactText(java.lang.String,
1115-
* int)
1116-
*/
11171070
public void clickLinkWithExactText(String linkText, int index) {
1118-
throw new UnsupportedOperationException("clickLinkWithExactText");
1119-
}
1120-
1121-
/**
1122-
* Navigate by submitting a request based on a link containing the specified
1123-
* text. A RuntimeException is thrown if no such link can be found.
1124-
*
1125-
* @param linkText
1126-
* text which link to be navigated should contain.
1127-
*/
1128-
public void clickLinkWithText(String linkText) {
1129-
clickLinkWithText(linkText, 0);
1130-
}
1131-
1132-
public void clickLinkWithText(String linkText, int index) {
1133-
HtmlAnchor link = getLinkWithText(linkText, index);
1071+
HtmlAnchor link = getLinkWithExactText(linkText, index);
11341072
if (link == null)
11351073
throw new RuntimeException("No Link found for \"" + linkText
11361074
+ "\" with index " + index);
@@ -1252,10 +1190,6 @@ public void clickLink(String anID) {
12521190
clickElementByXPath("//a[@id=\"" + anID + "\"]");
12531191
}
12541192

1255-
private HtmlAnchor getLinkWithText(String linkText) {
1256-
return getLinkWithText(linkText, 0);
1257-
}
1258-
12591193
private HtmlAnchor getLinkWithImage(String filename, int index) {
12601194
return (HtmlAnchor) getElementByXPath("(//a[img[contains(@src,\""
12611195
+ filename + "\")]])[" + index + 1 + "]");
@@ -1272,6 +1206,17 @@ private HtmlAnchor getLinkWithText(String linkText, int index) {
12721206
return null;
12731207
}
12741208

1209+
private HtmlAnchor getLinkWithExactText(String linkText, int index) {
1210+
List lnks = ((HtmlPage) win.getEnclosedPage()).getAnchors();
1211+
int count = 0;
1212+
for (int i = 0; i < lnks.size(); i++) {
1213+
HtmlAnchor lnk = (HtmlAnchor) lnks.get(i);
1214+
if ((lnk.asText().equals(linkText)) && (count++ == index))
1215+
return lnk;
1216+
}
1217+
return null;
1218+
}
1219+
12751220
/**
12761221
* Navigate by submitting a request based on a link with a given image file
12771222
* name. A RuntimeException is thrown if no such link can be found.
@@ -1440,19 +1385,6 @@ public void unselectOptions(String selectName, String[] options) {
14401385
}
14411386
}
14421387

1443-
/**
1444-
* Select an option of a select box by value.
1445-
*
1446-
* @param selectName
1447-
* name of the select box.
1448-
* @param option
1449-
* value of the option to select.
1450-
*/
1451-
public void selectOptionByValue(String selectName, String option) {
1452-
HtmlSelect sel = getForm().getSelectByName(selectName);
1453-
sel.setSelectedAttribute(option, true);
1454-
}
1455-
14561388
public boolean isTextInElement(String elementID, String text) {
14571389
return isTextInElement(getElement(elementID), text);
14581390
}

0 commit comments

Comments
 (0)