Skip to content

Commit

Permalink
Further minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
shs96c committed Dec 28, 2018
1 parent 4f77e95 commit 0e49330
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
*/
@Deprecated
public class KeyDownAction extends SingleKeyAction implements Action {

public KeyDownAction(Keyboard keyboard, Mouse mouse, Locatable locationProvider, Keys key) {
super(keyboard, mouse, locationProvider, key);
}
Expand All @@ -48,8 +49,7 @@ public void perform() {

@Override
public List<Interaction> asInteractions(PointerInput mouse, KeyInput keyboard) {

ArrayList<Interaction> interactions = new ArrayList<>(optionallyClickElement(mouse));
List<Interaction> interactions = new ArrayList<>(optionallyClickElement(mouse));
interactions.add(keyboard.createKeyDown(key.getCodePoint()));

return Collections.unmodifiableList(interactions);
Expand Down
7 changes: 3 additions & 4 deletions java/client/src/org/openqa/selenium/support/PageFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;


/**
Expand Down Expand Up @@ -67,8 +66,8 @@ public static <T> T initElements(WebDriver driver, Class<T> pageClassToProxy) {
}

/**
* As {@link org.openqa.selenium.support.PageFactory#initElements(org.openqa.selenium.WebDriver,
* Class)} but will only replace the fields of an already instantiated Page Object.
* As {@link #initElements(WebDriver, Class)} but will only replace the fields of an already
* instantiated Page Object.
*
* @param driver The driver that will be used to look up the elements
* @param page The object with WebElement and List&lt;WebElement&gt; fields that
Expand Down Expand Up @@ -128,7 +127,7 @@ private static <T> T instantiatePage(WebDriver driver, Class<T> pageClassToProxy
} catch (NoSuchMethodException e) {
return pageClassToProxy.newInstance();
}
} catch (InstantiationException | IllegalAccessException | InvocationTargetException e) {
} catch (ReflectiveOperationException e) {
throw new RuntimeException(e);
}
}
Expand Down
19 changes: 6 additions & 13 deletions java/client/test/com/thoughtworks/selenium/I18nTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@
import org.junit.Before;
import org.junit.Test;

import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;

public class I18nTest extends InternalSelenseTestBase {

@Before
Expand All @@ -32,36 +29,36 @@ public void navigateToPage() {
}

@Test
public void testRomance() throws UnsupportedEncodingException {
public void testRomance() {
String expected =
"\u00FC\u00F6\u00E4\u00DC\u00D6\u00C4 \u00E7\u00E8\u00E9 \u00BF\u00F1 \u00E8\u00E0\u00F9\u00F2";
String id = "romance";
verifyText(expected, id);
}

@Test
public void testKorean() throws UnsupportedEncodingException {
public void testKorean() {
String expected = "\uC5F4\uC5D0";
String id = "korean";
verifyText(expected, id);
}

@Test
public void testChinese() throws UnsupportedEncodingException {
public void testChinese() {
String expected = "\u4E2D\u6587";
String id = "chinese";
verifyText(expected, id);
}

@Test
public void testJapanese() throws UnsupportedEncodingException {
public void testJapanese() {
String expected = "\u307E\u3077";
String id = "japanese";
verifyText(expected, id);
}

@Test
public void testDangerous() throws UnsupportedEncodingException {
public void testDangerous() {
String expected = "&%?\\+|,%*";
String id = "dangerous";
verifyText(expected, id);
Expand All @@ -76,13 +73,9 @@ public void testDangerousLabels() {
Assert.assertEquals("mangled label", "c:\\I came, I \\saw\\, I conquered", labels[2]);
}

private void verifyText(String expected, String id) throws UnsupportedEncodingException {
private void verifyText(String expected, String id) {
assertTrue(selenium.isTextPresent(expected));
String actual = selenium.getText(id);
byte[] result = actual.getBytes(StandardCharsets.UTF_8);
for (int i = 0; i < result.length; i++) {
Byte b = new Byte(result[i]);
}
Assert.assertEquals(id + " characters didn't match", expected, actual);
}

Expand Down

0 comments on commit 0e49330

Please sign in to comment.