0

我需要帮助与 Flash 元素交互。我有一个网站,我需要在其中单击一个 Web 元素(看起来像下拉菜单)。当我检查时,该元素位于嵌入标签中。
有人可以指导我,如何使用 webdriver 单击该下拉菜单?

下面是该元素的代码:

<embed width="100%" height="675" 
flashvars="FQDN=http://modules.nike.com/&amp;buildConfigDataPath=http://nikeid.nike.com//fl
ashbuilder/xml/builder_config_only_en_US.xml&amp;buildTranslationPath=http://nikeid.nike.co
m//flashbuilder/xml/builder_text_one_en_US.xml&amp;lang_locale=en_US&amp;country=US&amp;cha
nnel=NT&amp;builderVersion=5&amp;productId=KDVI1308&amp;pathName=KDVI1308&amp;siteId=70&amp
;site=nikestore&amp;reportSuiteId=nikestorehtml&amp;productDescription=&lt;div&gt;&lt;h2&gt
;&lt;p&gt;Shipping's On Us&lt;/p&gt;&lt;br&gt;Get free shipping on orders of $75 or 
more.&lt;/br&gt;&lt;/h2&gt;&lt;/div&gt;&amp;startState=&amp;productSubtitle=Basketball 
Shoe&amp;preBuildPidMap=
{%22849037353%22:%22876749%22,%22636023234%22:%22876565%22,%22677905765%22:%22876659%22,%22
445353336%22:%22876616%22,%22423118083%22:%22876601%22,%22849370668%22:%22876622%22,%221026
723049%22:%22876583%22,%22135535177%22:%22876719%22,%22615163280%22:%22876794%22,%225887890
12%22:%22876779%22,%22527892069%22:%22876701%22,%22771023503%22:%22876764%22,%22713459235%2
2:%22876683%22,%22114065227%22:%22876677%22,%22332876321%22:%22876556%22,%22276725909%22:%2
2876704%22,%22244861767%22:%22876761%22,%22683303572%22:%22876746%22,%22326876232%22:%22876
610%22,%22943443020%22:%22876643%22,%221041527770%22:%22876737%22,%22591365975%22:%22876770%22,%22510055084%22:%22876662%22,%22552594165%22:%22876695%22,%22576022675%22:%22876592%22,%22597176009%22:%22876628%22,%22582310926%22:%22876782%22,%22139640153%22:%22876791%22,%22845044066%22:%22876680%22,%22742924768%22:%22876752%22,%22193771630%22:%22876743%22,%221061919588%22:%22876707%22,%22858328304%22:%22876686%22,%22963882283%22:%22876788%22,%22379409489%22:%22876598%22,%22557430186%22:%22876740%22,%22657948930%22:%22876698%22,%22317136451%22:%22876595%22,%22522593025%22:%22876562%22,%22866153878%22:%22876776%22,%22313194433%22:%22876755%22,%22670541939%22:%22876665%22,%22827995284%22:%22876568%22,%221010986160%22:%22876613%22,%22246627539%22:%22876571%22,%221000934072%22:%22876725%22,%22530451646%22:%22876646%22,%22984719501%22:%22876535%22,%22280677738%22:%22876671%22,%22335471662%22:%22876767%22,%22222978666%22:%22876692%22,%22794492005%22:%22876577%22,%22260110124%22:%22876650%22,%22771658112%22:%22876710%22,%22426642464%22:%22876728%22,%22990022635%22:%22876580%22,%22566491287%22:%22876547%22,%22350330855%22:%22876773%22,%22356738982%22:%22876541%22,%22994400434%22:%22876625%22,%22498712354%22:%22876656%22,%22511509538%22:%22876559%22,%22150025740%22:%22876637%22,%22732240969%22:%22876653%22,%22309534568%22:%22876589%22,%22890535189%22:%22876674%22,%22599320262%22:%22876634%22,%22501175907%22:%22876640%22,%22740705916%22:%22876631%22,%22704542572%22:%22876734%22,%22383139159%22:%22876785%22,%22660784765%22:%22876716%22,%22569357134%22:%22876722%22,%22473353058%22:%22876574%22,%22485339531%22:%22876607%22,%221025220278%22:%22876586%22,%22205105532%22:%22876550%22,%22440800436%22:%22876713%22}&amp;p
rebuildId=260110124&amp;productInstanceId=33505&amp;itemReturnURL=http%3A%2F%2Fstore.nike.c
om%2Fus%2Fen_us%2Fproduct%2Fkd-6-chroma-
id%2F%3Fpiid%3D33505%26pbid%3D260110124%23%3Fpbid%3D260110124" 
allowscriptaccess="always" pluginspage="http://www.adobe.com/products/flashplayer/" 
wmode="opaque" salign="tl" scale="noscale" loop="false" menu="false" 
allowfullscreen="true" requiredversion="9.0.28" quality="high" name="builderID" 
id="builderID" style="height: 915px;" 
src="http://nikeid.nike.com//flashbuilder/modules/standaloneIDBuilder.swf" 
type="application/x-shockwave-flash">


在下面尝试,但需要一些编码

public static void main(String[] args) throws InterruptedException {
 driver= new FirefoxDriver();
 driver.get("http://<FlashAppTest>");
 driver.manage().window().maximize();
 Test flashApp = new Test();
 flashApp.callFlashObject("Play"); }
public String callFlashObject(final String functionName, final String... args) {
final Object result =
    ((JavascriptExecutor)driver).executeScript(
            makeJsFunction(functionName, args),
            new Object[0]);
    return result != null ? result.toString() : null;
}
          private String makeJsFunction(final String functionName, final String... args) {
final StringBuffer functionArgs = new StringBuffer();
if (args.length > 0) {
    for (int i = 0; i < args.length; i++) {
        if (i > 0) {
            functionArgs.append(",");
        }
        functionArgs.append(String.format("'%1$s'", args[i]));
    }
}
return String.format(
        "return document.%1$s.%2$s(%3$s);",
        flashObjectId,
        functionName,
        functionArgs);
    }

请指导如何使用 webdriver 实现这一目标?

4

0 回答 0