Search
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
» Geting issues in identifying the elsements in webdriver
Fri Feb 17, 2017 4:41 pm by janbaskt

» WebDriver - why not to use a singlton for it?
Fri Feb 17, 2017 4:40 pm by janbaskt

» WebDriver session when using testng annotation to invoke driver instance
Fri Feb 17, 2017 4:39 pm by janbaskt

» Selenium fails to launch Chrome
Fri Feb 17, 2017 4:39 pm by janbaskt

» why do i get this error
Fri Feb 17, 2017 4:38 pm by janbaskt

» Selenium Tutorial
Thu Feb 16, 2017 5:21 pm by Rahul

» When to use Selenium IDE, RC and WebDriver
Mon Feb 13, 2017 2:35 pm by azharuddin

» How to integrate selenium with ZAPI-Zephyr
Sat Feb 11, 2017 2:25 am by gseera002c

» Selenium Webdriver
Sat Feb 04, 2017 6:47 pm by soumyamishrav@gmail.com

Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

Click works Intermittently

View previous topic View next topic Go down

Click works Intermittently

Post by disallowed on Wed Nov 26, 2014 3:32 am

I have this strange issue. The purpose of the test is to login and click an element. The login test seems to work consistently but clicking an element after login seems to work intermittently. If I run the test 10 times, it seem to work 4 times.
 
driver.get("SomeWebsite");
              driver.manage().window().maximize();
              driver.manage().timeouts().pageLoadTimeout(1, TimeUnit.MINUTES);
              driver.findElement(By.xpath("//li[2]/a")).click();
              driver.manage().timeouts().pageLoadTimeout(100, TimeUnit.SECONDS);
              driver.findElement(By.cssSelector("input[id*='textfield']")).sendKeys("someemail");
              driver.findElement(By.cssSelector("input[type*='password']")).sendKeys("password");
              driver.findElement(By.xpath("//div[3]/em/button")).click();
             
             
The codes seem to work fine upto here. However, the below code is the one I am having the issue.
 
 
 
WebElement myDynamicElement = (new WebDriverWait(driver, 10))
.until(ExpectedConditions.presenceOfElementLocated(By.id("header")));
             
 
driver.findElement(By.xpath("//li/a")).click(); 
 
Testnging does not detect that the element was not clicked and does not report any failures. 
             

disallowed

Posts : 1
Join date : 2014-11-26

Back to top Go down

Re: Click works Intermittently

Post by shweta.bet on Fri Dec 05, 2014 7:39 am

This looks like synchronisation issue. Webdriver is trying to find an elemnt before it loads. Better you can try writing customized ocde for wait,

Code:
public
static WebElement waitForElementPresent(final
By by,
int
timeOutInSeconds) throws UnsupportedEncodingException
{
WebElement
element;
try{
driver.manage().timeouts().implicitlyWait(0, TimeUnit.SECONDS); //nullify
implicitlyWait()WebDriverWait
wait =
new
WebDriverWait(driver, timeOutInSeconds);
element = wait.until(ExpectedConditions.presenceOfElementLocated(by));resetImplicitWait(12);
//reset
implicitlyWait
return element; //return the
element
}

catch (Exception
e)
{

writer.Exception(e.getMessage());
}

return
null;
}

shweta.bet

Posts : 7
Join date : 2014-11-14
Age : 34

Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum