Java Code Examples for org.openqa.selenium.remote.RemoteWebElement#setId()

The following examples show how to use org.openqa.selenium.remote.RemoteWebElement#setId() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PointerInputTest.java    From selenium with Apache License 2.0 6 votes vote down vote up
@Test
public void encodesWrappedElementInMoveOrigin() {
  RemoteWebElement innerElement = new RemoteWebElement();
  innerElement.setId("12345");
  WebElement element = new WrappedWebElement(innerElement);

  PointerInput pointerInput = new PointerInput(Kind.MOUSE, null);
  Interaction move = pointerInput.createPointerMove(
      Duration.ofMillis(100), Origin.fromElement(element), 0, 0);
  Sequence sequence = new Sequence(move.getSource(), 0).addAction(move);

  String rawJson = new Json().toJson(sequence);
  ActionSequenceJson json = new Json().toType(
      rawJson,
      ActionSequenceJson.class,
      PropertySetting.BY_FIELD);

  assertThat(json.actions).hasSize(1);
  ActionJson firstAction = json.actions.get(0);
  assertThat(firstAction.origin).containsEntry(W3C.getEncodedElementKey(), "12345");
}
 
Example 2
Source File: UsingPageFactoryTest.java    From selenium with Apache License 2.0 6 votes vote down vote up
@Test
public void testDecoratedElementsShouldBeUnwrapped() {
  final RemoteWebElement element = new RemoteWebElement();
  element.setId("foo");

  WebDriver driver = mock(WebDriver.class);
  when(driver.findElement(new ByIdOrName("element"))).thenReturn(element);

  PublicPage page = new PublicPage();
  PageFactory.initElements(driver, page);

  Object seen = new WebElementToJsonConverter().apply(page.element);
  Object expected = new WebElementToJsonConverter().apply(element);

  assertThat(seen).isEqualTo(expected);
}
 
Example 3
Source File: WebElementToJsonConverterTest.java    From selenium with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void convertsAListWithAWebElement() {
  RemoteWebElement element = new RemoteWebElement();
  element.setId("abc123");

  RemoteWebElement element2 = new RemoteWebElement();
  element2.setId("anotherId");

  Object value = CONVERTER.apply(asList(element, element2));
  assertThat(value).isInstanceOf(Collection.class);

  List<Object> list = new ArrayList<>((Collection<Object>) value);
  assertThat(list).hasSize(2);
  assertIsWebElementObject(list.get(0), "abc123");
  assertIsWebElementObject(list.get(1), "anotherId");
}
 
Example 4
Source File: WebElementToJsonConverterTest.java    From selenium with Apache License 2.0 5 votes vote down vote up
@Test
public void convertsRemoteWebElementToWireProtocolMap() {
  RemoteWebElement element = new RemoteWebElement();
  element.setId("abc123");

  Object value = CONVERTER.apply(element);
  assertIsWebElementObject(value, "abc123");
}
 
Example 5
Source File: WebElementToJsonConverterTest.java    From selenium with Apache License 2.0 5 votes vote down vote up
@Test
public void unwrapsWrappedElements() {
  RemoteWebElement element = new RemoteWebElement();
  element.setId("abc123");

  Object value = CONVERTER.apply(wrapElement(element));
  assertIsWebElementObject(value, "abc123");
}
 
Example 6
Source File: WebElementToJsonConverterTest.java    From selenium with Apache License 2.0 5 votes vote down vote up
@Test
public void unwrapsWrappedElements_multipleLevelsOfWrapping() {
  RemoteWebElement element = new RemoteWebElement();
  element.setId("abc123");

  WrappedWebElement wrapped = wrapElement(element);
  wrapped = wrapElement(wrapped);
  wrapped = wrapElement(wrapped);
  wrapped = wrapElement(wrapped);

  Object value = CONVERTER.apply(wrapped);
  assertIsWebElementObject(value, "abc123");
}
 
Example 7
Source File: WebElementToJsonConverterTest.java    From selenium with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void convertsAMapWithAWebElement() {
  RemoteWebElement element = new RemoteWebElement();
  element.setId("abc123");

  Object value = CONVERTER.apply(ImmutableMap.of("one", element));
  assertThat(value).isInstanceOf(Map.class);

  Map<String, Object> map = (Map<String, Object>) value;
  assertThat(map.size()).isEqualTo(1);
  assertIsWebElementObject(map.get("one"), "abc123");
}
 
Example 8
Source File: WebElementToJsonConverterTest.java    From selenium with Apache License 2.0 5 votes vote down vote up
@Test
public void convertsAnArrayWithAWebElement() {
  RemoteWebElement element = new RemoteWebElement();
  element.setId("abc123");

  Object value = CONVERTER.apply(new Object[] { element });
  assertContentsInOrder(new ArrayList<>((Collection<?>) value),
      ImmutableMap.of(
        Dialect.OSS.getEncodedElementKey(), "abc123",
        Dialect.W3C.getEncodedElementKey(), "abc123"));
}