无法在即将到来的 ajax 叠加弹出窗口中单击或发送键,并且其显示 Element not Intractable exception using selenium 和 java

Unable to click or sendKeys in ajax overlay popup coming and its showing Element not Intractable exception using selenium and java

我一直在练习自动化 Web 应用程序的几个场景 way2Automation.com 并努力在弹出窗口中输入注册表单中的文本。 我已经做了一些研究并尝试了下面提到的许多方法:

a) 使用 WebDriverWait 和显式等待 b) 使用隐式等待和 Thread.sleep c) 使用 JavaScriptExecutor

但其中 none 为我工作,我仍然坚持注册用户。非常感谢您的帮助。以下是神器

URL: http://way2automation.com/way2auto_jquery/index.php

代码试验:

1)

//  WebElement ele = driver.findElement(By.xpath("//*[@id='load_form']/div/div[2]/input"));
//  JavascriptExecutor executor = (JavascriptExecutor)driver;
//  executor.executeScript("arguments[0].click();", ele);
//  WebElement button = driver.findElement(By.xpath("//*[@id=\"load_form\"]/div/div[2]/input"));
//  new WebDriverWait(driver, 10).until(ExpectedConditions.visibilityOf(button));

要单击 提交,您可以使用以下任一方法

  • cssSelector:

    driver.findElement(By.cssSelector("input.button[value='Submit']")).click();
    
  • xpath:

    driver.findElement(By.xpath("//input[@class='button' and @value='Submit']")).click();
    

但是,由于该元素是一个动态元素,所以要在该元素上 click() 您需要为 elementToBeClickable() 引入 并且您可以使用以下任一项 :

  • cssSelector:

    new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.cssSelector("input.button[value='Submit']"))).click();
    
  • xpath:

    new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//input[@class='button' and @value='Submit']"))).click();
    

参考

您可以在以下位置找到关于 的详细讨论:

You need to handle windows
Try the below code and let me know updates

 driver.get("http://way2automation.com/way2auto_jquery/index.php");
        String parent=driver.getWindowHandle();
        String child=driver.getWindowHandle();
        driver).switchTo().window(child);
        driver.findElement(By.name("name")).sendKeys("Abhishek Saxena");