开发者

Selenium 2 Webdriver cant find element by xpath after upgrading from firefox 4 to 5

开发者 https://www.devze.com 2023-03-22 13:39 出处:网络
I\'m attempting to write a te开发者_如何学Cst which will click on a description box and type in a quick description. When using Selenium 2.0 with Firefox 4, I was using the code:

I'm attempting to write a te开发者_如何学Cst which will click on a description box and type in a quick description. When using Selenium 2.0 with Firefox 4, I was using the code:

      WebElement venueDescription = driver.findElement(By.xpath("//iframe[contains(@id,'Frame')]"));

   venueDescription.sendKeys("This is a description for the Venue");

To do this. However, after upgrading to firefox 5 and Selenium 2.1, I'm receiving a "unable to locate element" error. Here's a copy of the code. The first and third textareas are hidden, so i use the contains() to select the second textarea. This was working fine until the update.

<input id="cf_textarea1311363997499___Config" type="hidden" style="display:none" value="LinkBrowserURL=%2FCFIDE%2Fscripts%2Fajax%2FFCKeditor%2Feditor%2Ffilemanager%2Fbrowser%2Fdefault%2Fbrowser.html%3FConnector%3D..%2F..%2Fconnectors%2Fcfm%2Fconnector.cfm%26_cf_clientid%3D242D1F3D48B023DBFB61177D36938485&LinkUploadURL=%2FCFIDE%2Fscripts%2Fajax%2FFCKeditor%2Feditor%2Ffilemanager%2Fconnectors%2Fcfm%2Fupload.cfm%3F_cf_clientid%3D242D1F3D48B023DBFB61177D36938485&ImageBrowserURL=%2FCFIDE%2Fscripts%2Fajax%2FFCKeditor%2Feditor%2Ffilemanager%2Fbrowser%2Fdefault%2Fbrowser.html%3FType%3DImage%26Connec...e%3DImage%26_cf_clientid%3D242D1F3D48B023DBFB61177D36938485&FlashBrowserURL=%2FCFIDE%2Fscripts%2Fajax%2FFCKeditor%2Feditor%2Ffilemanager%2Fbrowser%2Fdefault%2Fbrowser.html%3FType%3DFlash%26Connector%3D..%2F..%2Fconnectors%2Fcfm%2Fconnector.cfm%26_cf_clientid%3D242D1F3D48B023DBFB61177D36938485&FlashUploadURL=%2FCFIDE%2Fscripts%2Fajax%2FFCKeditor%2Feditor%2Ffilemanager%2Fconnectors%2Fcfm%2Fupload.cfm%3FType%3DFlash%26_cf_clientid%3D242D1F3D48B023DBFB61177D36938485&AutoDetectLanguage=false&DefaultLanguage=en">
<iframe width="0" scrolling="no" height="0" frameborder="0" src="javascript:void(0)" style="position: absolute; z-index: 10000;">
<iframe width="0" scrolling="no" height="0" frameborder="0" src="javascript:void(0)" style="position: absolute; z-index: 10000;">
<iframe width="0" scrolling="no" height="0" frameborder="0" src="javascript:void(0)" style="position: absolute; z-index: 10000;">
<iframe width="0" scrolling="no" height="0" frameborder="0" src="javascript:void(0)" style="position: absolute; z-index: 10000;">
<iframe width="0" scrolling="no" height="0" frameborder="0" src="javascript:void(0)" style="position: absolute; z-index: 10000;">
<iframe width="0" scrolling="no" height="0" frameborder="0" src="javascript:void(0)" style="position: absolute; z-index: 10000;">
<iframe id="cf_textarea1311363997499___Frame" width="675" scrolling="no" height="200" frameborder="0" src="/CFIDE/scripts/ajax/FCKeditor/editor/fckeditor.html?InstanceName=cf_textarea1311363997499&Toolbar=BasicText">
<textarea id="cf_textarea1311363997499" name="description" style="display: none;"></textarea>


Have you tried switching to the iFrame first, before interacting with it?

On the website I test, everything is embedded in iFrames and before I can get to any of the elements in them, I first have to switch to them, like this:

driver.switchTo().defaultContent();
driver.switchTo().frame(driver.findElement(By.xpath("//iFrame[@id='Frame']")));
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号