2 u011591297 u011591297 于 2016.04.29 23:37 提问

selenium webdriver测试问题 15C

想测试网页元素:
http://www.indeed.ca/cmp/Family-Futures-Resource-Network/jobs/Family-Enrichment-Worker-3396e3ab27d0f1d4?sjdu=vQIlM60yK_PwYat7ToXhk8zp-Ak3kDWvkMS3L0Xyb01JfHXPO97qnuWgnEA72HSmJKa9WargHenL42bqgqZ_Hv0HB1mLXN5mVeoFrhMf1ZE

1.点击"Apply Now",会弹出一个iframe,想操作iframe中的元素,但是总是提示元素找不到。

想请大神帮忙看看,哪里存在问题?.java文件已经包含在附件里

public class howToWorkWithIframe2 {

WebDriver driver;
String baseUrl;

@Before
public void setUp() throws Exception {
    driver = new FirefoxDriver();
    baseUrl = "http://www.indeed.ca/cmp/Family-Futures-Resource-Network/jobs/Family-Enrichment-Worker-3396e3ab27d0f1d4?sjdu=vQIlM60yK_PwYat7ToXhk8zp-Ak3kDWvkMS3L0Xyb01JfHXPO97qnuWgnEA72HSmJKa9WargHenL42bqgqZ_Hv0HB1mLXN5mVeoFrhMf1ZE";
    driver.manage().window().maximize();
    driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
}

@Test
public void test() throws InterruptedException {
    driver.get(baseUrl);

    Thread.sleep(3000);
    driver.findElement(By.xpath("//a[@class = 'indeed-apply-button']")).click();;
    driver.switchTo().frame("indeedapply-modal-preload-iframe");
    driver.findElement(By.xpath(".//*[@id='applicant.name']")).sendKeys("success!");;

}

@After
public void tearDown() throws Exception {
}

}

3个回答

CSDNXIAON
CSDNXIAON   2016.04.29 23:42

Selenium webdriver 常见问题
Selenium Webdriver 处理隐藏元素的问题
Selenium WebDriver
----------------------同志你好,我是CSDN问答机器人小N,奉组织之命为你提供参考答案,编程尚未成功,同志仍需努力!

devmiao
devmiao   Ds   Rxr 2016.04.29 23:56
u011591297
u011591297   2016.04.30 00:18

二楼,没太看懂你发的连接的意思

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!