Ich arbeite mit Selenium Automation. Wenn ich auf einen Link in einem aktuellen Fenster klicke, öffnet sich ein neues Fenster. Ich möchte nur das Steuerelement in das neue Fenster wechseln. Aber ich kann das nicht tun. Eigentlich ist das neue Fenster ein automatisch generiertes Fenster. Das heißt, Link wird dynamisch generiert. Hilf mir, Freunde.Fensterschalter funktioniert nicht in Selen
import java.io.File;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
public class UAN {
public static void main(String[] args) {
File file = new File("D:\\IEDriverServer.exe");
System.setProperty("webdriver.ie.driver", file.getAbsolutePath());
WebDriver driver = new InternetExplorerDriver();
driver.get("http://intraeasy.techmahindra.com/easyhome.aspx");
System.out.println(driver.getTitle());
String Parent_Window = driver.getWindowHandle();
System.out.println("Main window value: "+Parent_Window);
//CLick to open new window
driver.findElement(By.linkText("People Search")).click();
// Switching from parent window to child window
for (String Child_Window : driver.getWindowHandles())
driver.switchTo().window(Child_Window);
{
// Performing actions on child window
driver.findElement(By.xpath("/html/body/form/table/tbody/tr/td/table/tbody/tr[2]/td/table/tbody/tr[5]/td/table/tbody/tr[4]/td/table/tbody/tr[2]/td[2]/table/tbody/tr[2]/td/table/tbody/tr[1]/td[2]/input")).sendKeys("test");
// Switching back to Parent Window
driver.switchTo().window(Parent_Window);
}
}
}
Der Code gibt beim Ausführen dieser Zeile einen Fehler unterhalb des Fehlers aus.
driver.findElement(By.xpath("/html/body/form/table/tbody/tr/td/table/tbody/tr[2]/td/table/tbody/tr[5]/td/table/tbody/tr[4]/td/table/tbody/tr[2]/td[2]/table/tbody/tr[2]/td/table/tbody/tr[1]/td[2]/input")).sendKeys("test");
Exception in thread "main" org.openqa.selenium.NoSuchElementException: Unable to find element with name == notetext (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 5.11 seconds