New answers tagged

0

I had put my code to implement for new webdriver code as below ,refer this page: https://github.com/becausetesting/commons/blob/master/src/main/java/com/github/becausetesting/cucumber/selenium/RemoteWebDriverEx.java : just use this code to use existing started selenium session: WebDriver driver=new RemoteWebDriverEx(true); full code as below sample: ...


0

I hope this might help public void waitForPageLoad(WebDriver driver){ ExpectedCondition<Boolean> expectation = new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver driver) { return ((JavascriptExecutor)driver).executeScript("return document.readyState").equals("complete"); } }; Wait<WebDriver> wait = ...


0

An element you interacting become stale when it is destroyed and recreated. Hence when page refreshes, every element in that page become stale. So we can check if the page is refreshed by waiting for an element in that page to become stale. The following Java code illustrate how it is achieved using Selenium webdriver. If the page is not refreshed in 30 ...


0

You can make use of window.sessionStorage. You can ask development to define an pre-defined object, for example reloadflag="true". You will check the value for true with window.sessionStorage.getItem("reloadflag") After each check you have to set the value to false with window.sessionStorage.setItem("reloadflag", "false") If you do not have possibility ...


2

If you're talking about bringing the browser's window within the OS to the foreground. Selenium cannot do that. You need to introduce a library that is able to automate actions on an OS level. Selenium is restricted by javascript's same origin policy. Looks like you're using Java, so you could take a look at awt.Robot. But be aware that any solution you ...


0

I used sikuli to detect whether the browser is out of focus since it can see outside the browser window (usually on mac you can see the name of the application on top bar) and then used robot class to do a command+tab. I think you can also use java script executor to pop up an alert so that browser comes to focus before each test suite.


1

Ask development to place a HTML comment that has the timestamp, e.g. <!-- 06-jan-2016 08:09--> or add it to the actual page so that tools that have access to the full dom can easily access it, but make it not display on the browser <div display:none">06-jan-2016 08:09</div> If it has to be present but not visible then <div ...


3

One possible way is to force a change in a parallel session or in the database with a script. Then you can keep polling for some seconds until the new data becomes visible. I would expect the feature is not to refresh the page, but to refresh to show new data. Test the feature, not only the known behavior, thus test why the page refreshes instead. Ask ...


0

A possible solution for this issue could be to find the label control containing the value you are looking to select, then find the child control (which should be the radio button) then selecting the radio button. String labelToFind = "Senior"; BrowserWindow browser = BrowserWindow.Launch(@"pathToHTMLFile"); HtmlLabel theLabelToFind = ...


0

You need to find the element and than extract the text from it. Following is the code for the same. WebElement element = driver.findElement(By.xpath("//div[@class='f1']/p")); String text = element.getText();


0

We had faced same issues in the past. On node server before launching new node check any existing instance was running. Forcefully close the browser instances before again passing control back. Added bat file to do this functionality. It works perfect.


0

If you want to implement dynamic wait, try this: WebDriverWait wait = new WebDriverWait(driver, 30); wait.until(elementToBeClickable(By.xpath(".//*[@id='header2']/nav/div/ul/li/a"))).click(); instead of this: Thread.sleep(3000); driver.findElement(By.xpath(".//*[@id='header2']/nav/div/ul/li/a")).click();



Top 50 recent answers are included