CKEditor + Selenium WebDriver不再适用于FireFox 9/10 [英] CKEditor + Selenium WebDriver not work with FireFox 9/10 anymore

查看:81
本文介绍了CKEditor + Selenium WebDriver不再适用于FireFox 9/10的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在移至FF9 / 10之前,此行sendKeys可以与FF8.0.1 + Selenium 2.18配合使用。但是在将FF升级到9和10之后,sendKeys在CKEditor中将一无所获。也不例外,没有警告。我想知道这是否是CKEditor的错误吗?还是FF 9/10?还是WebDriver?有人对此有线索吗?

  DesiredCapabilities wantedCapabilities = DesiredCapabilities.firefox(); 
wantedCapabilities.setPlatform(Platform.WINDOWS);
URL remoteAddress = new URL( http://127.0.0.1:4444/wd/hub);
RemoteWebDriver驱动程序=新的RemoteWebDriver(remoteAddress,desiredCapabilities);
driver.get( http://ckeditor.com/demo);
WebElement元素= driver.findElement(By.id( cke_contents_editor1))。findElement(By.tagName( iframe));
element.sendKeys( Cheese!);

当然,我可以像下面那样直接访问CKEditor的实例,但这只是一种解决方法。 / p>

((JavascriptExecutor)concorddriver).executeScript( CKEDITOR.instances.editor1.insertText('hello'););

解决方案

如果 sendKeys()不起作用,尝试使用 click()



这通常有助于解决类似问题。



但是在尝试之前,请检查是否确实找到了该元素!



如果没有,请检查该元素的ID是否仍然相同,并且/或尝试使用其他 By。方法(例如 By.className(),...)


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' );");

解决方案

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(),...)

这篇关于CKEditor + Selenium WebDriver不再适用于FireFox 9/10的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆