Module 21 - Rediff.com portfolio rename or delete function | Selenium Forum
M
Posted on 04/07/2016
Dear Ashish,

How to handle this situation in selenium webdriver.
Note: I was using chrome browser for all this test.

please view module 21 video (2 and 3), you have performed rename of portfolio and deleting renamed portfolio. I tried the way you did and it was working fine but I got error when I tried to delete different portfolio other than just renamed portfolio.

Step:
1.Select a portfolio, click rename button
2.Enter Rename text and click ok button in the light box
3.Select portfolio to be deleted from the option list
4.click Delete button and ok in the alert window

But, the real problem is webdriver immediately selects portfolio to be deleted but in fraction of second it is replaced by renamed portfolio and page is refreshed. I get StaleElementException or otherwise some other element receives the click.

It worked when i used Thread.sleep option to make webdriver wait until renamed portfolio page refreshed. I would like to know is there any alternative way to make webdriver to wait (note: i tried explicit wait but no use as portfolio to be deleted is displayed and got replaced)

could you try it and provide solution. This would be great.

Thanks
Sathish kumar

M
Replied on 04/07/2016

thread.sleep and explicit wait are the only way deal with StaleElementException.

show me how are you using explicit code. send the 2 line of code.


M
Replied on 05/07/2016

Thanks Ashish...

Here is my explicit wait, i have tried below 3 options:
I have defined my WebDriverWait Objref at class level

wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.xpath("//*[@id='portfolioid']/option[text()='"+deletePortfolioName+"']")));


wait.until(ExpectedConditions.elementToBeSelected(By.xpath("//*[@id='portfolioid']/option[text()='"+deletePortfolioName+"']")));

also i tried:

while(!driver.findElement(By.xpath("//*[@id='portfolioid']/option[text()='"+deletePortfolioName+"']")).isSelected()){
dropList.selectByVisibleText(deletePortfolioName);
}


Thanks for your response....


M
Replied on 06/07/2016

those above methods are fine try these also.

https://gist.github.com/djangofan/5112655