Page 1 of 1
[ASK] input text ke dalam iFrame Text Editor (Selenium - TestNG Java)
Posted: Wed Mar 11, 2020 11:46 am
by farvan
Hallo saya mau tanya gimana ya cara input ke dalam text editor yang ada di dalam iFrame.
ini pakainya Text editor dari FCKeditor.
Form Text Editor
Code Text Editor
apa ada yang pernah handle form kayak gini?
Re: [ASK] input text ke dalam iFrame Text Editor (Selenium - TestNG Java)
Posted: Thu Mar 12, 2020 11:21 am
by farvan
Solve
Code: Select all
if (!VISION.equalsIgnoreCase("")) {
String[] st_desc = VISION.split(", ");
String[] lang = LANG.split(", ");
for(int i = 0;i < st_desc.length;i++) {
try {
wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.xpath("//*[@id=\"inp_vision_"+ lang[i] +"___Frame\"]")));
wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.xpath("//*[@id=\"xEditingArea\"]/iframe")));
WebElement body = driver.findElement(By.tagName("body"));
if(body != null) {
System.out.println("body "+i+" exist");
} else {
System.out.println("body "+i+" not exist");
}
System.out.println(lang[i]); // debug
System.out.println(st_desc[i]); // debug
body.clear();
body.sendKeys(st_desc[i]);
Thread.sleep(500);
test.get().pass("<small>[Input FCK Text Editor]</small> Vision : " + st_desc[i]);
driver.switchTo().parentFrame();
} catch(Exception e) {
System.out.println("Error. "+e.getMessage());
}
System.out.println("loop "+i); // debug
driver.switchTo().parentFrame();
}
Thread.sleep(500);
}