CKEditor + Selenium WebDriver not work with FireFox 9/10 anymore

梦想与她 提交于 2020-01-05 07:09:41

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!