--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
My first suggestion would be bin the try/catch, modify your code to be:
Public Boolean isElementPresent(By by){
return driver.findElements(by).size() > 0
}
There could be many reasons for slow code, you haven’t shown us everything so we don’t know what else you are doing. Also bear in mind that during debugging things will be slower.
--
Yes, upvote! This is almost certainly the cause of the symptoms described. Debugged and fixed many along my travels in Selenium
On Thursday, November 8, 2012 1:11:55 PM UTC+11, Andrew Muraco wrote:Are you setting an implicit wait time on the driver?A line like this:driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);Would be a culprit of the delay.An alternative way to get around this issue is to do:return driver.findElements(by).size() == 0;and not bother with the try/catch at all.-Andrew
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/9K4N2caWegIJ.
For a start you are setting implicitly wait for 30 second (never use implicitly wait, that’s only used by people who aren’t sure what they are doing). That will slow things down in general as for every call it will wait up to 30 seconds.
I would write that code as:
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.WebDriverWait;
import static org.openqa.selenium.support.ui.ExpectedConditions.visibilityOfElementLocated;
public class Google_Test {
private static final String baseUrl = "http://www.gmail.com/";
private static WebDriver driver;
private static WebDriverWait wait;
@Before
public void setUp() throws Exception {
driver = new FirefoxDriver();
//Set up a wait object that waits a maximum of 15 seconds, checking the condition every 100 milliseconds
wait = new WebDriverWait(driver, 15, 100);
}
@Test
public void Create_New_Account() throws Exception {
//Ensure we are in a logged out state when starting test
driver.manage().deleteAllCookies();
//Navigate to website
driver.navigate().to(baseUrl);
//TODO create a login page object for all the below
//Log In
driver.findElement(By.id("Email")).sendKeys("yourus...@gmail.com");
driver.findElement(By.id("Passwd")).sendKeys("Hello123");
driver.findElement(By.id("signIn")).click();
//Check we are logged in
WebElement composeButton = wait.until(visibilityOfElementLocated(By.cssSelector("div[class='T-I J-J5-Ji T-I-KE L3']")));
//TODO do something with the compose button?
driver.findElement(By.id("Email")).sendKeys("yourusername...@gmail.com");
driver.findElement(By.id("Email")).sendKeys("yourusername...@gmail.com");
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/1KJ1Do5KzkwJ.
driver.FindElement(By.Id("Email")).SendKeys("yourusername...@gmail.com");
driver.findElement(By.id("Email")).sendKeys("yourusername@gmail.com");
driver.findElement(By.id("Email")).sendKeys("yourusername@gmail.com");
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/Rt_dcSSYQbwJ.