I want to test paypal payment with selenium/selenide.
I am waiting for the embedded frame to be loaded, then switch to it, fill out the login form and click the login button.
but how can I wait from there for the next step to be loaded? (there is a significant load-time between the steps that happens after the iframe was initially loaded, so the waitForLoad doesn't catch it)
I have tried waitForLoad(confirmButton), but it timeouts. (I'm still in the iframe focus).
how can I do this?
thanks
Use wait command:
public void waitForElementPresent() {
WebDriverWait wait = new WebDriverWait(driver, 20);
wait.until(ExpectedConditions
.visibilityOfElementLocated(By.id("");
}
Related
1.Newsletter pop up shows up on my site.
2.This newsletter pop up modal can show up on any page within 3 minutes so I can not time it.
This was making my automation script (using geb-spock) fail.
In order to now show the newsletter pop up modal, I added a below cookies.
driver.manage().addCookie(new Cookie("signupNoThanks", "optedNoThanks"));
Error message
`selenium.ElementClickInterceptedException` error i.e `Element <element1> is not clickable at point (1085,112) because another element <Newletter pop up modal> obscures it`
I tried to print the cookies and I can see it in the logs
[![Cookies log ss][1]][1]
Can anyone suggest what's wrong on the Firefox browser, cookies added by me works perfectly fine on chrome but fails some automated test cases sometimes on firefox. Is firefox blocking us because of some security reasons?
[1]: https://i.stack.imgur.com/lS1r7.png
The error does seem to be specific to cookies, as you are able to see the cookies in the log. The error 'Element is not clickable' is a generic error you can read more about it on Selenium Web Driver & Java. Element is not clickable at point (x, y). Other element would receive the click
Try the following ways to resolve this error
Try using a different selector like XPath to locate the element.
The element is not visible in the Viewport, could you try scrolling to the element before clicking on it?
Use Actions class to perform the click.
You could create an extension method for clicks used throughout the project and wrap it in a try catch for element intercepted exception. You could then accept the popup and continue on as normal without caring about it.
(below code is c#):
public static class SeleniumExtensions
{
public static void ClickElement(this IWebElement element)
{
try
{
element.Click();
} catch (ElementClickInterceptedException ex)
{
Console.WriteLine("Click was intercepted, attempting to dismiss pop up: ", ex);
//Code to click or dismiss your popup goes here
//retry click
element.Click();
}
}
}
Then throughout the project instead of using the default selenium click use:
element.ClickElement();
I'm automating the salesforce web application. After logging into the application the home page loads and then gets refreshed not able to identify the locators due to the refresh happens after 2 to 3 sec. Refresh is happing to load the dashboards.
Getting an Exception:org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element
I had tried with webdriverwait, Thread.sleep and Implicitwait and none of these options worked out for me.
public void validatedashboard() throws InterruptedException{
new WebDriverWait(driver, 15).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//button[contains(text(),'Open')]")));
String actualdashboard = dashboard.getText();
BasePage.Log.info(actualdashboard);
String ExpectedText0= "Territory Overview";
if(actualdashboard.contentEquals(ExpectedText0))
{
BasePage.Log.info("Territory Overview dashboard is present");
}
else
{
BasePage.Log.info("Territory Overview dashboard is not present");
}
I'm trying to write a piece of code using Testng in selenium, the problem is when i try to click a link, the code becomes unresponsive and gives error- Timed out receiving message from renderer
Tried driver.get("https://infostore.saiglobal.com/") instead of driver.findElement(By.linkText("Infostore")).click(); still remains unresponsive - Doesnot get directed to the webpage - https://infostore.saiglobal.com/
#Test
public void testSai() throws Exception {
driver.get("https://www.saiglobal.com/"); //open homepage
driver.findElement(By.id("CybotCookiebotDialogBodyButtonAccept")).click(); //accept cookie
driver.findElement(By.cssSelector("#sai-header > div > div.main-nav > div.store-box > div")).click(); //click on Login to open list
sleep(2);
driver.findElement(By.linkText("Infostore")).click(); //click on infostore to be redirected to https://infostore.saiglobal.com/
System.out.println(driver.getCurrentUrl());
Yes I have checked this issue and there is an workaround for this issue if you wish to have this.Try following code.
Take the href attribute value from the link element.
Delete all cookies.
driver.navigate().to(URL);
public static void main(String[] args){
System.setProperty("webdriver.chrome.driver", System.getProperty("user.dir") + File.separator + "\\Executables\\Chromedriver.exe");
WebDriver driver = new ChromeDriver();
WebDriverWait wait = new WebDriverWait(driver, 5);
Actions actions = new Actions(driver);
driver.get("https://www.saiglobal.com/");
driver.findElement(By.id("CybotCookiebotDialogBodyButtonAccept")).click();
WebElement element=wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//div[#class='desktop-login']")));
actions.moveToElement(element).build().perform();
WebElement element1=wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//div[#class='desktop-login']/ul/li/a[contains(text(),'Infostore')]")));
String str1=element1.getAttribute("href");
driver.manage().deleteAllCookies();
driver.navigate().to(str1);
System.out.println(driver.getCurrentUrl());
}
This seems to be an error with Selenium that the developers have been dealing with for over a year. They never really give a concrete answer as to what causes it or how to fix it.
The first port of call would be to make sure that your browser and Selenium are compatible. Try opening a different URL that you know works, and if the error persists then there is likely an error with the compatibility of your selenium and web browser. If it works, then there is something wrong with your website.
For reference, I opened your website using Python Selenium, and had no issues loading or interacting with elements. So the error is local to the software you are using.
The issue can also be caused by sleeps(no idea why), so try removing any sleeps and see if this stops the issue.
I have logged into an account on one of the websites. After login, a click on a button presents that page, but the page keeps on loading without displaying the next page.
What I wanted is, if the page keeps on loading without giving any response for some time, I need to stop the execution of the script.
I have tried by using the below code, but it didn't work
driver.manage().timeouts().pageLoadTimeout(500, TimeUnit.MILLISECONDS);
If you are using firefox, use firefox profile with selenium and set network.http.connection-timeout to seconds (for ex I am setting it to 10 secs) -
In Java,
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("network.http.connection-timeout", 10);
For stopping the page-load you can use this
public void stopPageLoading() {
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("return window.stop");
}
I have a Selenium 2 test that uses a login form and then asserts that the login has succeeded by verifying the page title has changed.
The test is written in Java/JUnit, WebDriver and Fluent Selenium
fwd.title().within(secs(5)).shouldContain(partialTitle);
The tests work on Firefox and Chrome.
On Safari the page title is still the old login page title.
The screencast we have generated shows that the URL after a successful login has changed, but the title hasn't.
I think the SafariDriver is not waiting for the page load event to complete before the assertion.
I have the same issue!!!
My test fail because title is used for checking test "Step".
With Firefox and Chrome no problem; with Safari it's a problem!!!
I found this "hack" that work, but it's necessary to manually check the title after each "click":
def static void waitForPage(driver, String title) {
//Hack to make login working on Safari&IE
(new WebDriverWait(driver, 10)).until(new ExpectedCondition<Boolean>() {
public Boolean apply(WebDriver d) {
return d.getTitle().startsWith(title);
}
});
}
I use GEB + SPOCK and with safari driver there is a "know issue" about implicit/explicit wait (ref. https://code.google.com/p/selenium/issues/detail?id=5860).
So, a nice workaround for make test runnable on Safari browser is to wait for page title:
static at = {
waitFor { title == "Homepage" }
}
This will force the driver to wait until title change (the timeout is configurable).