0

这是html:

<frame name="Chooser" scrolling="YES" src="/Dispatcher?page=JobSkillsRolesEntry&sig=ZUVPdTRjeGNoSDM2cFBXNDZPc3RBam5uLzZzPTtZMlJsTVRaak1UVXRNakE1WXkwME9USmlMVGt4TkdJdFltSXdZV1ZrTVRreU9UWXg7cGFnZQ%3D%3D" marginheight=0 noresize>
<frameset rows="70,*" framespacing=0 frameborder="1">
    <frame name="SkillSearch" scrolling="NO" src="/Dispatcher?page=skillsRolesSearchPage&sig=WllqYlZRekpKMXV1RlVmOW1FaWlQQ3BXS0tjPTtZMlJsTVRaak1UVXRNakE1WXkwME9USmlMVGt4TkdJdFltSXdZV1ZrTVRreU9UWXg7cGFnZQ%3D%3D" marginheight=0 noresize>
    <frame name="SkillList" scrolling="YES" src="/Dispatcher?page=categoryPage&sig=dytiNVRQayswWUJISzF0TGxJNVQ1MFpCZFM0PTtZMlJsTVRaak1UVXRNakE1WXkwME9USmlMVGt4TkdJdFltSXdZV1ZrTVRreU9UWXg7cGFnZQ%3D%3D" marginheight=0>
</frameset>

这是使用帧索引的代码:

    driver.switchTo().defaultContent();
    driver.switchTo().defaultContent().switchTo().frame(0);
    logger.info("Found Chooser Frame");
    driver.switchTo().frame(1);
    logger.info("Found SkillSearch Frame");
    driver.switchTo().defaultContent().switchTo().frame(0);
    driver.switchTo().frame(2);
    logger.info("Found SkillList Frame");
    driver.findElement(By.xpath("html/body/form/table/tbody/tr[2]/td[1]/a")).click();
    driver.switchTo().defaultContent();

这是我使用名称时不起作用的代码:

    driver.switchTo().defaultContent();
    driver.switchTo().defaultContent().switchTo().frame("Chooser");
    logger.info("Found Chooser Frame");
    driver.switchTo().frame("SkillSearch");
    logger.info("Found SkillSearch Frame");
    driver.switchTo().defaultContent().switchTo().frame("Chooser");
    driver.switchTo().frame("SkillList");
    logger.info("Found SkillList Frame");
    driver.findElement(By.xpath("html/body/form/table/tbody/tr[2]/td[1]/a")).click();
    driver.switchTo().defaultContent();

我想使用这个名字,因为它更干净。有任何想法吗

4

0 回答 0