You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 29, 2018. It is now read-only.
What steps will reproduce the problem?
1. Record a test case in IDE with one waitForElementPresent command.
2. Export this test case as Java/Junit/WebDriver.
3. Run the test case.
What is the expected output?
When the element is not present it should wait for 60 seconds and fail.
What do you see instead?
When the element is not present it is waiting for (60*30 = 1800) seconds and then fail.
Selenium version:2.44.0
OS: Windows8
Browser:All
Browser version:
Note: When the file is exported as java, the @Before method contains the implicit timeouts
of 30 seconds. The formatted code for waitForElementPresent contains a loop which iterates
60 seconds. But for each iteration isElementPresent method will wait for 30 seconds
and hence the timeout time is (60*30 = 1800) seconds.
I think the for loop should iterate only twice then after (2* 30 = 60) seconds time
out will occur.
Exported Test case:
package com.autorabit.tests;
import java.util.regex.Pattern;
import java.util.concurrent.TimeUnit;
import org.junit.*;
import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.*;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.Select;
public class JavaFormatterTest {
private WebDriver driver;
private String baseUrl;
private boolean acceptNextAlert = true;
private StringBuffer verificationErrors = new StringBuffer();
@Before
public void setUp() throws Exception {
driver = new FirefoxDriver();
baseUrl = "https://www.google.co.in/";
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
@Test
public void example() throws Exception {
driver.get(baseUrl + "/");
for (int second = 0;; second++) {
if (second >=60) fail("timeout");
try {
if (isElementPresent(By.xpath("//li[@id='xpath_which_is_not_present']"))) break;
} catch (Exception e) {}
}
Thread.sleep(1000);
}
@After
public void tearDown() throws Exception {
driver.quit();
String verificationErrorString = verificationErrors.toString();
if (!"".equals(verificationErrorString)) {
fail(verificationErrorString);
}
}
private boolean isElementPresent(By by) {
try {
driver.findElement(by);
return true;
} catch (NoSuchElementException e) {
return false;
}
}
private boolean isAlertPresent() {
try {
driver.switchTo().alert();
return true;
} catch (NoAlertPresentException e) {
return false;
}
}
private String closeAlertAndGetItsText() {
try {
Alert alert = driver.switchTo().alert();
String alertText = alert.getText();
if (acceptNextAlert) {
alert.accept();
} else {
alert.dismiss();
}
return alertText;
} finally {
acceptNextAlert = true;
}
}
}
Reported by shaikh.arifullah on 2015-03-04 10:58:45
The text was updated successfully, but these errors were encountered:
Originally reported on Google Code with ID 8562
Reported by
shaikh.arifullah
on 2015-03-04 10:58:45The text was updated successfully, but these errors were encountered: