A必须检查页面上是否存在AD,我可以单击它们。 iframe中的广告。任何人都可以帮我在iframe之间切换吗?还是有其他问题?谢谢! (使用Java,Selenium)。
这是我的代码(我的代码出错了):
WebDriver driver = new FirefoxDriver();
driver.get("http://website.com");
WebElement frameID = driver.findElement(By.id("google_ads_iframe_5480/5480.iac.dictionary/search_1"));
driver.switchTo().frame(frameID);
driver.switchTo().frame("cx_frame/300/250/ui65519851");
driver.findElement(By.xpath(".//*[@id='DCF278454593']/embed")).click();
这是错误:
无法找到框架:cx_frame / 300/250 / ui65519851
这是HTML:
<div style="margin-top:15px;text-align:center;padding-bottom:1px;">
<div id="dcomad_top_300x250_1">
<script type="text/javascript">
<div id="google_ads_iframe_5480/5480.iac.dictionary/search_1__container__" style="border: 0pt none;">
<div style="margin-top:15px;text-align:center;padding-bottom:1px;">
<div id="dcomad_top_300x250_1">
<script type="text/javascript">
<div id="google_ads_iframe_5480/5480.iac.dictionary/search_1__container__" style="border: 0pt none;">
<iframe id="google_ads_iframe_5480/5480.iac.dictionary/search_1" height="250" frameborder="0" width="300" scrolling="no" name="google_ads_iframe_5480/5480.iac.dictionary /search_1" marginwidth="0" marginheight="0" style="border: 0px none; vertical-align: bottom;" src="javascript:" <html><body style='background:transparent'></body></html>"">
<html>
<head>
<body>
<script>
<div id="ui65519851">
<iframe id="cx_frame/300/250/ui65519851" height="250" frameborder="0" width="300" scrolling="no" vspace="0" hspace="0" marginheight="0" marginwidth="0" allowtransparency="true" style="border:0px;margin:0px;padding:0px" name="cx_frame/300/250/ui65519851" src="http://ads.yahoo.com/getserved?bSClCaJAGgCf2dUAAAAAAIw5MgAAAAAAAgAAAAIAAAAAAP8AAAAGDUyMKgAAAAAA6lhDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADdEREAAAAAAAIAAgAAgD8AZmZmZmZm9j9mZmZmZmb2P2ZmZmZmZvY.ZmZmZmZm9j8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA7e80DzHvszPGXktuV.jg3qyi7uRsLR1.AAAAAA==,,dictionary.reference.com,,a0e913a8-8ab8-11e3-b3e4-a38a94b48bb0,1391201132949&click=[CLICKURL]#34714bad23eabd61b575c3d047b817b6">
<html>
<head>
<body style="margin-left: 0%; margin-right: 0%; margin-top: 0%; margin-bottom: 0%">
<img id="1391201134567111_18" height="0" width="0" name="1391201134567111_18" style="display: none;" src="">
<img id="1391201134567111_14" height="0" width="0" name="1391201134567111_14" style="display: none;" src="">
<img id="1391201134567111_13" height="0" width="0" name="1391201134567111_13" style="display: none;" src="http://tps10213.doubleverify.com/event.jpg?ctx=971108&cmp=7980225&ipos=&sid=1408130&plc=105721482&adid=&crt=56773841&dvtagver=6.1.src&srcurlD=1&curl=&qpgid=&btreg=278498536&btadsrv=doubleclick&adsrv=1&advid=4053494&num=&pid=&crtname=&unit=&chnl=&ssl=0&uid=1391201134567111&scusrid=&refD=2&aUrlD=1&jsver=470&eparams=DC4FC%3Dl9EEATbpTauTau5%3A4E%3A%40%3F2CJ%5DC676C6%3F46%5D4%40%3ETau3C%40HD6TauD62C49TbuDTbsEU2%26C%3Dl9EEATbpTauTau5%3A4E%3A%40%3F2CJ%5DC676C6%3F46%5D4%40%3ETau3C%40HD6TauD62C49TbuDTbsE&brid=2&brver=26&tstype=128&jsCallback=dvCallback_1391201134567278&TKH=-9219319569043728022&dvp_templateVersion=7&impid=8a3a35d862a0465cb641b37f0be9812e&istoms=900030&strp=100&adbtftopg=&adwdth=300&adhgt=250&isbxdms=900030&b0=449000&b11=2000&evid=3&ctime=1391202034801">
<iframe id="iframe_950197849502" height="0" width="0" name="iframe_950197849502" style="display: none;" src="about:blank">
<script type="text/javascript">
<script type="text/Javascript">
<script src="http://a1.interclick.com/getInPageJS.aspx?a=51&b=52852&cid=634649177146425381">
<script src="http://a1.interclick.com/getInPageJSProcess.aspx?a=51&b=52852&cid=634649177146425381&isif=t&rurld=dictionary.reference.com&sl=true&dvp=http%3A//dictionary.reference.com/browse/search%3Fs%3Dt&rurl=http%3A%2F%2Fdictionary.reference.com%2Fbrowse%2Fsearch%3Fs%3Dt" type="text/javascript" language="javascript">
<script src="https://ad.doubleclick.net/adj/N8667.1041586.YAHOOINCGENOMEFROM/B7980225.51;sz=300x250;pc=;click=http://a1.interclick.com/icaid/500920/tid/c3546c1a-4f76-4a62-983b-2fd58936ecca/click.ic?;ord=635267799337461821?" language="JavaScript1.1">
<script src="https://static.doubleclick.net/879366/flashwrite_1_2.js">
<object id="DCF278498536" height="250" width="300" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000">
<param value="https://static.doubleclick.net/4053494/COMW_DAT_14_1_GM_ACQ_NON_DAT Non-Sub Shell_NONE_NONE_NONE_NONE_FLASH_300x250.swf" name="movie">
<param value="moviePath=https://static.doubleclick.net/4053494/&moviepath=https://static.doubleclick.net/4053494/" name="flashvars">
<param value="high" name="quality">
<param value="opaque" name="wmode">
<param value="https://static.doubleclick.net/4053494" name="base">
<param value="always" name="AllowScriptAccess">
<span id="te-494f-icon" style="display: block; position: absolute; opacity: 0.8; overflow: hidden; margin: 0px; padding: 0px; z-index: 100002; width: 19px; height: 15px; cursor: pointer; left: 0px; top: 0px;">
<embed height="250" width="300" allowscriptaccess="always" base="https://static.doubleclick.net/4053494" name="DCF278498536" wmode="opaque" swliveconnect="true" quality="high" type="application/x-shockwave-flash" flashvars="moviePath=https://static.doubleclick.net/4053494/&moviepath=https://static.doubleclick.net/4053494/" src="https://static.doubleclick.net/4053494/COMW_DAT_14_1_GM_ACQ_NON_DAT Non-Sub Shell_NONE_NONE_NONE_NONE_FLASH_300x250.swf" dvvisit="971108-7980225">
</object>
<noscript><a target="_blank" href="https://ad.doubleclick.net/click%3Bh%3Dv8/3ee8/f/58/%2a/z%3B278498536%3B0-0%3B0%3B105721482%3B4307-300/250%3B56773841/56663044/1%3B%3B%7Esscs%3D%3fhttp://a1.interclick.com/icaid/500920/tid/c3546c1a-4f76-4a62-983b-2fd58936ecca/click.ic?http%3a%2f%2fwww.xfinity.com%3Fdfaid%3D4053494%26cmp%3D0%26cid%3D4053494"><img src="https://static.doubleclick.net/4053494/COMW_DAT_14_1_GM_ACQ_NON_DAT Non-Sub Shell-WEST-CorpAcq_NONE_NONE_NONE_NONE_STATIC_300x250.gif" width="300" height="250" border="0" alt="Advertisement" galleryimg="no"></a></noscript>
<script id="script_950197849502" type="text/javascript" src="https://cdn.doubleverify.com/dvtp_src.js?ctx=971108&cmp=7980225&sid=1408130&plc=105721482&num=&adid=&advid=4053494&adsrv=1®ion=30&btreg=278498536&btadsrv=doubleclick&crt=56773841&crtname=&chnl=&unit=&pid=&uid=&dvtagver=6.1.src">
<script type="text/javascript" src="https://choices.truste.com/ca?pid=comcast01&aid=comcast01&cid=%ebuy_1408130_105721482_56773841&js=st_0ex">
<noscript><a href="http://a1.interclick.com/getInPageTarget.aspx?a=51&b=52852&cid=634649177146425381"> <img src="http://a1.interclick.com/getInPageImage.aspx?a=51&b=52852&cid=634649177146425381" border='0'></a></noscript>
<script type="text/javascript" src="https://choices.truste.com/ca?aid=comcast01&pid=comcast01&cid=�uy_1408130_105721482_56773841&js=st_1&sz=300x250&c=te-494f&admarker=default&plc=tl&cam=3&zi=100002&sid=_LBsidLB_&locale=en">
<script src="https://choices.truste.com/ca?aid=comcast01&pid=comcast01&locale=en&c=_LBcLB_&cid=�uy_1408130_105721482_56773841&sid=_LBsidLB_&language=en&js=st_2&cam=3">
</body>
</html>
</iframe>
</div>
<script src="//cdn.beanstock.com/pub/cx/tag.js">
<iframe id="google_osd_static_frame_3577502476978" name="google_osd_static_frame" style="display: none; width: 0px; height: 0px;">
</body>
</html>
</iframe>
</div>
</div>
</div>