我正在運行一個Java轉換使用JDev的selenium 2.0腳本。我有一個例子,我打開一個模式窗口並搜索一個像%SomeText%
這樣的字符串,並且它會在它下面創建一個記錄,同一個窗口。現在,我想確保它已經生成了我正在查找的文本,並且如果我獲得了該文本,請在模式窗口中單擊「確定」。任何想法怎麼辦呢?我做了以下內容:無法讀取搜索結果使用硒2.0
//this is working
driver.findElement(By.id("_afrFilterpt1_afr__UISatr_afr_0_afr_AT1_afr__ATp_afr_t2_afr_c3::content")).sendKeys(Keys.RETURN);
//this doesn't work, text given here is part of the text which is returned after search
assertTrue((driver.findElements(By.xpath("contains(text(),'Approved:Create Grade Ladder (AU_New Grade Ladder205, 2012-08-31)')")).size() > 0) ? true:false);
//this works if above line is deleted, else this also does not work
driver.findElement(By.xpath("//button[text()='OK']")).click();
請添加HTML標記 – 2012-09-03 06:45:27
@ user1506541,別忘了標記答案! –