问题
Before moved to FF9/10, this line sendKeys can work well with FF8.0.1 + Selenium 2.18. But after upgrade FF to 9 and 10, sendKeys will get nothing in CKEditor. No exception, no warning. I am wondering if it is the bug of CKEditor? or FF 9/10? or WebDriver? Anyone have clue for this?
DesiredCapabilities desiredCapabilities = DesiredCapabilities.firefox();
desiredCapabilities.setPlatform(Platform.WINDOWS);
URL remoteAddress = new URL("http://127.0.0.1:4444/wd/hub");
RemoteWebDriver driver = new RemoteWebDriver(remoteAddress,desiredCapabilities);
driver.get("http://ckeditor.com/demo");
WebElement element = driver.findElement(By.id("cke_contents_editor1")).findElement(By.tagName("iframe"));
element.sendKeys("Cheese!");
Of course, I can access the instance of CKEditor directly like below, but it just a workaround.
((JavascriptExecutor) concorddriver).executeScript("CKEDITOR.instances.editor1.insertText( 'hello' );");
回答1:
If sendKeys()
doesn't work, try a click()
before using it.
This often helped on similar issues.
But before you try this, check if the element is really found!
If not check if the element's id is still the same and/or try to use other By.
methods (like By.className()
,...)
来源:https://stackoverflow.com/questions/9357223/ckeditor-selenium-webdriver-not-work-with-firefox-9-10-anymore