Issue 7357 in selenium: WebElement.sendKeys fails when sending empty list

26 katselukertaa
Siirry ensimmäiseen lukemattomaan viestiin

sele...@googlecode.com

lukematon,
16.5.2014 klo 2.36.5816.5.2014
vastaanottaja selenium-develope...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium Status-Untriaged

New issue 7357 by tim.myer...@permeance.com.au: WebElement.sendKeys fails
when sending empty list
http://code.google.com/p/selenium/issues/detail?id=7357

Attempting to send an empty array of keys to remote web driver fails. The
same code against a local FirefoxDriver succeeds.

Error seen:
java.util.MissingFormatArgumentException: Format specifier 's'
at java.util.Formatter.format(Formatter.java:2487)
at java.util.Formatter.format(Formatter.java:2423)
at java.lang.String.format(String.java:2797)


Example Test Case to reproduce:

import org.junit.Test;
import org.openqa.selenium.remote.server.Session;
import
org.openqa.selenium.remote.server.handler.interactions.SendKeyToActiveElement;

public class SendKeysTest {

@Test
public void sendEmptyKeys() {

SendKeyToActiveElement sendKeys = new
SendKeyToActiveElement(mock(Session.class));
sendKeys.toString();

}

}

I'll submit a pull request/patch to fix.

--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

sele...@googlecode.com

lukematon,
16.5.2014 klo 2.50.1416.5.2014
vastaanottaja selenium-develope...@googlegroups.com

Comment #1 on issue 7357 by tim.myer...@permeance.com.au:
WebElement.sendKeys fails when sending empty list
http://code.google.com/p/selenium/issues/detail?id=7357

Added patch file

Attachments:
Fix-issue-7357.patch 5.1 KB

sele...@googlecode.com

lukematon,
17.5.2014 klo 6.08.4917.5.2014
vastaanottaja selenium-develope...@googlegroups.com
Updates:
Cc: nirvd...@gmail.com francois...@gmail.com
Labels: Component-Grid

Comment #2 on issue 7357 by barancev: WebElement.sendKeys fails when
(No comment was entered for this change.)

sele...@googlecode.com

lukematon,
28.6.2014 klo 17.32.4328.6.2014
vastaanottaja selenium-develope...@googlegroups.com
Updates:
Status: NeedsClarification

Comment #3 on issue 7357 by barancev: WebElement.sendKeys fails when
Is there a way to reproduce this issue using public WebDriver API, without
mocking?

sele...@googlecode.com

lukematon,
1.7.2014 klo 20.53.521.7.2014
vastaanottaja selenium-develope...@googlegroups.com

Comment #4 on issue 7357 by tim.myer...@permeance.com.au:
WebElement.sendKeys fails when sending empty list
http://code.google.com/p/selenium/issues/detail?id=7357

Yes,

The code I was running was using a RemoteWebDriver to clear the text from a
rich text editor. Sending CTRL+A +backspace didn't work for me.

WebDriver driver = ... // A remote web driver instance is injected.
WebElement contents = ... // The focussed iFrame contents

Actions actions = new Actions(driver);

int charsToDelete = contents.getText().length();
CharSequence[] deleteKeys = new CharSequence[charsToDelete];
Arrays.fill(deleteKeys, Keys.BACK_SPACE);
actions.sendKeys(contents, deleteKeys).perform();
Arrays.fill(deleteKeys, Keys.DELETE);
actions.sendKeys(contents, deleteKeys).perform();

However, in order to isolate the failure in a unit test, I used mocking to
simulate the resulting calls (with the same behaviour as experienced during
debugging the real thing). Otherwise, there would be a large amount of
setup code to perform the test, which could confuse things.

sele...@googlecode.com

lukematon,
23.7.2014 klo 19.22.2423.7.2014
vastaanottaja selenium-develope...@googlegroups.com

Comment #5 on issue 7357 by barancev: WebElement.sendKeys fails when
I can't reproduce the issue. Here is the code:

RemoteWebDriver driver = new
RemoteWebDriver(DesiredCapabilities.firefox());
driver.get("http://ckeditor.com/demo");


driver.switchTo().frame(driver.findElement(By.className("cke_wysiwyg_frame")));
WebElement contents = driver.findElement(By.tagName("body"));

int charsToDelete = contents.getText().length();

Actions actions = new Actions(driver);

CharSequence[] deleteKeys = new CharSequence[charsToDelete];
Arrays.fill(deleteKeys, Keys.BACK_SPACE);
actions.sendKeys(contents, deleteKeys).perform();
Arrays.fill(deleteKeys, Keys.DELETE);
actions.sendKeys(contents, deleteKeys).perform();
driver.quit();

And the server log:

03:08:01.607 INFO - Done: [new session: Capabilities [{platform=ANY,
browserName
=firefox, version=}]]
03:08:01.626 INFO - Executing: [get: http://ckeditor.com/demo])
03:08:04.607 INFO - Done: [get: http://ckeditor.com/demo]
03:08:04.615 INFO - Executing: [find element: By.className:
cke_wysiwyg_frame])
03:08:04.692 INFO - Done: [find element: By.className: cke_wysiwyg_frame]
03:08:04.698 INFO - Executing: [switch to frame: [[FirefoxDriver: firefox
on WIN
DOWS (ab82f24c-8a9f-4457-b5fc-70132a81c460)] -> class name:
cke_wysiwyg_frame]])

03:08:04.749 INFO - Done: [switch to frame: [[FirefoxDriver: firefox on
WINDOWS
(ab82f24c-8a9f-4457-b5fc-70132a81c460)] -> class name: cke_wysiwyg_frame]]
03:08:04.753 INFO - Executing: [find element: By.tagName: body])
03:08:04.805 INFO - Done: [find element: By.tagName: body]
03:08:04.809 INFO - Executing: [get text: 1 [[FirefoxDriver: firefox on
WINDOWS
(ab82f24c-8a9f-4457-b5fc-70132a81c460)] -> tag name: body]])
03:08:04.886 INFO - Done: [get text: 1 [[FirefoxDriver: firefox on WINDOWS
(ab82
f24c-8a9f-4457-b5fc-70132a81c460)] -> tag name: body]]
03:08:04.894 INFO - Executing: [mousemove: 1 false])
03:08:04.945 INFO - Done: [mousemove: 1 false]
03:08:04.949 INFO - Executing: [click: nothing])
03:08:05.028 INFO - Done: [click: nothing]
03:08:05.046 INFO - Executing: [send keys to active: ?])
03:08:07.852 INFO - Done: [send keys to active: ?]
03:08:07.856 INFO - Executing: [mousemove: 1 false])
03:08:07.907 INFO - Done: [mousemove: 1 false]
03:08:07.910 INFO - Executing: [click: nothing])
03:08:07.962 INFO - Done: [click: nothing]
03:08:07.975 INFO - Executing: [send keys to active: ?])
03:08:10.855 INFO - Done: [send keys to active: ?]
03:08:10.859 INFO - Executing: [delete session:
c5bdc1af-a7ca-46bd-ba0a-b0866210
e83d])
03:08:12.911 INFO - Command failed to close cleanly. Destroying forcefully
(v2).
org.openqa.selenium.os.UnixProcess$SeleniumWatchDog@6121237b
03:08:13.787 INFO - Done: [delete session:
c5bdc1af-a7ca-46bd-ba0a-b0866210e83d]

Yes, it does not clean the editor window. But contents.clear() does work as
expected.
Also actions.sendKeys(contents, Keys.CONTROL + "ax").perform() does the
trick.

But the main problem is that I can't reproduce the issue.

sele...@googlecode.com

lukematon,
1.9.2014 klo 10.18.421.9.2014
vastaanottaja selenium-develope...@googlegroups.com
Updates:
Status: WontFix

Comment #6 on issue 7357 by barancev: WebElement.sendKeys fails when
sending empty list
https://code.google.com/p/selenium/issues/detail?id=7357

Closing the issue as there is no known way to reproduce it (via external
public API).

sele...@googlecode.com

lukematon,
1.9.2014 klo 20.41.521.9.2014
vastaanottaja selenium-develope...@googlegroups.com

Comment #7 on issue 7357 by tim.myer...@permeance.com.au:
WebElement.sendKeys fails when sending empty list
https://code.google.com/p/selenium/issues/detail?id=7357

Sorry, but this issue is reproducible for me. Please can you re-open.

Looking back at my comments, it looks like I didn't provide enough
information. Apologies.

The test case you use won't reproduce the problem since the CKEditor in the
demo is not empty. This is a particular issue with the IEDriver/Grid, but
is down to a logic bug in SendKeyToActiveElement.

Setup:
* Grid 2 hub running on localhost, with a Node running IE on a Windows
machine.


package au.com.permeance.test;

import java.net.URL;
import java.util.Arrays;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.remote.Augmenter;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;

public class WebKeysTest {

private WebDriver driver;

@Before
public void setup() throws Exception {
DesiredCapabilities capabilities;
capabilities = DesiredCapabilities.internetExplorer();

capabilities.setCapability(InternetExplorerDriver.IE_ENSURE_CLEAN_SESSION,
true);
String seleniumGridHubHost = "localhost";
URL remoteAddress = new URL(String.format("http://%s:4444/wd/hub/",
seleniumGridHubHost));
driver = new RemoteWebDriver(remoteAddress, capabilities);
driver = new Augmenter().augment(driver);
}

@After
public void teardown() {
driver.quit();
}

@Test
public void test() {
driver.get("http://ckeditor.com/demo");


driver.switchTo().frame(driver.findElement(By.className("cke_wysiwyg_frame")));
WebElement contents = driver.findElement(By.tagName("body"));

Actions actions = new Actions(driver);

final int NONE = 0;

CharSequence[] deleteKeys = new CharSequence[NONE];

Arrays.fill(deleteKeys, Keys.BACK_SPACE);
actions.sendKeys(contents, deleteKeys).perform();
Arrays.fill(deleteKeys, Keys.DELETE);
actions.sendKeys(contents, deleteKeys).perform();
}

}

sele...@googlecode.com

lukematon,
1.9.2014 klo 20.44.321.9.2014
vastaanottaja selenium-develope...@googlegroups.com

Comment #8 on issue 7357 by tim.myer...@permeance.com.au:
WebElement.sendKeys fails when sending empty list
https://code.google.com/p/selenium/issues/detail?id=7357

Build info: version: '2.42.2',
revision: '6a6995d31c7c56c340d6f45a76976d43506cd6cc', time: '2014-06-03
10:52:47'
System info: host: 'xxx', ip: '127.0.0.1', os.name: 'Linux',
os.arch: 'amd64', os.version: '3.15.10-200.fc20.x86_64',
java.version: '1.7.0_45'

Selenium grid version 2.42.2
Internet Explorer Driver- 2.42.2 (32-bit)
Internex Explorer 10.0.9200.17028

sele...@googlecode.com

lukematon,
2.9.2014 klo 1.22.592.9.2014
vastaanottaja selenium-develope...@googlegroups.com
Updates:
Status: Accepted
Labels: -Status-Untriaged

Comment #9 on issue 7357 by barancev: WebElement.sendKeys fails when
Reproduced, thanks!
Have you signed the CLA http://goo.gl/qC50R ?

sele...@googlecode.com

lukematon,
2.9.2014 klo 2.52.222.9.2014
vastaanottaja selenium-develope...@googlegroups.com

Comment #10 on issue 7357 by tim.myer...@permeance.com.au:
WebElement.sendKeys fails when sending empty list
https://code.google.com/p/selenium/issues/detail?id=7357

Yep, CLA Signed.

sele...@googlecode.com

lukematon,
2.9.2014 klo 6.05.432.9.2014
vastaanottaja selenium-develope...@googlegroups.com
Updates:
Status: Fixed

Comment #11 on issue 7357 by barancev: WebElement.sendKeys fails when
This issue was closed by revision 9350102067ae.
Vastaa kaikille
Vastaa kirjoittajalle
Välitä
0 uutta viestiä