Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我需要添加一个等待,直到使用SeleniumJava从AngularHTTP请求中获得响应_Java_Angularjs_Http_Selenium_Selenium Chromedriver - Fatal编程技术网

我需要添加一个等待,直到使用SeleniumJava从AngularHTTP请求中获得响应

我需要添加一个等待,直到使用SeleniumJava从AngularHTTP请求中获得响应,java,angularjs,http,selenium,selenium-chromedriver,Java,Angularjs,Http,Selenium,Selenium Chromedriver,我对selenium非常陌生,我正在尝试编写一个代码,该代码将登录到我的网站,检查下拉列表并单击按钮。 单击按钮后,将触发http角度请求并显示结果。我的要求是等待响应并使用selenium检查响应,然后从我的网站注销 driver = new ChromeDriver(); driver.get("https://url"); driver.findElement(By.id("userId")).sendKeys("USERID"); driver.find

我对selenium非常陌生,我正在尝试编写一个代码,该代码将登录到我的网站,检查下拉列表并单击按钮。 单击按钮后,将触发http角度请求并显示结果。我的要求是等待响应并使用selenium检查响应,然后从我的网站注销

    driver = new ChromeDriver();

    driver.get("https://url");
    driver.findElement(By.id("userId")).sendKeys("USERID");
    driver.findElement(By.id("password")).sendKeys("PASSWORD");
    driver.findElement(By.id("Submit")).click();

    Select dropdownA = new Select(driver.findElement(By.id("mySelectA")));
    dropdownA.selectByValue("2");
    Select dropdownB = new Select(driver.findElement(By.id("mySelectB")));
    dropdownB.selectByValue("5");

    driver.findElement(By.id("findroute")).click();

    /***/Here i need to wait for the angular http request to reply and check for the data displayed***

    driver.findElement(By.id("userTemp")).click();
    driver.findElement(By.linkText("Logout")).click();
    driver.close();

首先,让我们在启动驱动程序后添加一些隐式等待。现在这是selenium等待任何元素(包括angular)的默认时间

driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);

现在让我们考虑元素A在用户执行的一些动作之后出现。元素A是有角度的,我是说。现在检查元素是否存在

driver.findElement(By.id(""));  
//Perform the required operations  after finding the element
脚本等待60秒,以显示角度元素。如果现在我们将得到元素未找到异常

其次,,我们可以使用显式等待来实现相同的目标

WebDriverWait wait = new WebDriverWait(webDriver, timeoutInSeconds);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id<locator>));
WebDriverWait wait=new-WebDriverWait(webDriver,timeoutingseconds);
等待.直到(预期条件.元素的可视性(通过.id));

wait.until(ExpectedConditions.elementtobelickable(By.id));

希望这对你有帮助。谢谢。

首先,让我们在启动驱动程序后添加一些隐式等待。现在这是selenium等待任何元素(包括angular)的默认时间

driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);

现在让我们考虑元素A在用户执行的一些动作之后出现。元素A是有角度的,我是说。现在检查元素是否存在

driver.findElement(By.id(""));  
//Perform the required operations  after finding the element
脚本等待60秒,以显示角度元素。如果现在我们将得到元素未找到异常

其次,,我们可以使用显式等待来实现相同的目标

WebDriverWait wait = new WebDriverWait(webDriver, timeoutInSeconds);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id<locator>));
WebDriverWait wait=new-WebDriverWait(webDriver,timeoutingseconds);
等待.直到(预期条件.元素的可视性(通过.id));

wait.until(ExpectedConditions.elementtobelickable(By.id));

希望这对你有帮助。谢谢。

您指定了要求。您的问题是什么?我需要等待angular http请求的答复并检查显示的数据。数据将以表格结构显示在HTMLYou指定的要求上。您的问题是什么?我需要等待angular http请求的答复并检查显示的数据。数据将以表格结构显示在HTMLW上,如果响应不会在timeoutInSeconds内出现,我是否应将其保持为60 WebDriverWait wait=new WebDriverWait(driver,60);对你可以增加时间。默认情况下,隐式等待将适用于所有元素,但webdriver wait适用于该特定元素。如果响应不会在TimeoutSeconds内出现,我是否应将其保持为60 WebDriverWait wait=new WebDriverWait(driver,60);对你可以增加时间。隐式等待将是所有元素的默认值,但webdriver等待适用于该特定元素。