Selenium Forum: Functional And Regression Testing Tool.
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Search
Display results as :
Advanced Search
Latest topics
AEM Training | Free Online DemoWed Apr 21, 2021 5:45 pmazharuddin
c# PageFactory - issue initializing elementsFri Nov 01, 2019 8:40 pmthegoatboy
Selenium making automatic connection to random urlsMon Jul 08, 2019 12:58 pmrepairtechsolutions1
How can we design the custom framework in Selenium RCMon Jun 24, 2019 2:26 pmrandybonnettes
What are the new features in Selenium 3.0Tue Jun 18, 2019 5:37 pmpappyvicky
What are you using Selenium for? Fri Apr 12, 2019 3:52 amzhl
LIMITATIONS OF SELENIUMWed Apr 10, 2019 11:23 amswara
Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

Go down
avatar
disallowed
Posts : 1
Join date : 2014-11-26

Click works Intermittently  Empty Click works Intermittently

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. 
             
avatar
shweta.bet
Posts : 7
Join date : 2014-11-14
Age : 41

Click works Intermittently  Empty Re: Click works Intermittently

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;
}
Back to top
Permissions in this forum:
You cannot reply to topics in this forum