<div>
<iframe id="cq-cf-frame ">
<iframe id="gen367">
<body spellcheck="false" id="CQrte" style="height: 255px; font-size: 12px; font-family:tahoma,arial,helvetica,sans-serif; background-image: url("/libs/cq/ui/widgets/themes/default/ext/form/text-bg.gif"); background-repeat: repeat-x; background-attachment: fixed;">
<p>4t43t4<br></p>
</body >
</iframe>
</iframe>
</div>
In questo scenario c'è un iframe
sotto iframe
. E devo selezionare l'esterno iframe
per andare al numero interno iframe
e scrivere nel corpo che si trova nel numero interno iframe
.Come gestire iframe in selenio WebDriver utilizzando Java
Successivamente, devo uscire dall'interno iframe
all'esterno iframe
e fare clic sul pulsante OK, (che si trova nell'esterno iframe
).
seguito è il mio codice
/*Line 1 */ driver.switchTo().frame("cq-cf-frame");
/* 2 */ driver.findElement(By.css("#extdd-9 > div.tblRow > input.edititem").click();
/* 3 */ driver.switchT().Frame("cq-gen379");
/* 4 */ driver.findElement(By.id("CQrte").sendKeys("Tnx");
/* 5 */ selenium.selectFrame("relative=up");
/* 6 */ driver.findElement(By.xpath("//button[text()='OK']")).click();
seguito è il mio problema:
Il mio codice di prova sta lavorando bene fino alla linea numero 4 cioè scrivendo nel corpo, ma voglio venire da interno a esterno iframe
dice che l'elemento //button[text()='OK']
non trovato.
Ho provato con l'utilizzo dell'indice, genitore, relativo, ma non ho avuto fortuna.
NOTA: Se non si seleziona frame interno (cq-gen379). Sono in grado di fare clic sul pulsante OK
.
Inoltre, come una FYI: ho trovato che il frame switchTo(). Ha bisogno di attesa implicita disattivata: driver.manage(). Timeouts(). ImplicitlyWait (0, TimeUnit.SECONDS); – JohnP2