Clicking link kills test
-
27-09-2019 - |
Question
The following command
selenium.click("link=Identify Awards");
opens a popup however the the test does not continue
I have placed
selenium.waitForPopUp(null, "1500");
selenium.windowFocus();
selenium.selectPopUp("Search -- Webpage Dialog");
After the click command to no avail the link is to a goes to a java function.
I know that this command Clicks on a link, button, checkbox or radio button. If the click action causes a new page to load (like a link usually does), call
waitForPageToLoad
.
I think that the waitforPageToLoad
is not registering the popup loading
Update
I tried the following
selenium.fireEvent("link=Identify Awards", "onClick");
and got the following
The popup is on another domain could this be the cause?
Exception in thread "Main Thread" org.openqa.selenium.ie.UnexpectedJavascriptExecutionException: Cannot execute script
System info: os.name: 'Windows Vista', os.arch: 'x86', os.version: '6.1', java.version: '1.5.0_12'
Driver info: driver.version: ie
at org.openqa.selenium.ie.ErrorHandler.verifyErrorCode(ErrorHandler.java:70)
at org.openqa.selenium.ie.InternetExplorerDriver.executeScript(InternetExplorerDriver.java:205)
at org.openqa.selenium.internal.seleniumemulation.JavascriptLibrary.callEmbeddedSelenium(JavascriptLibrary.java:47)
at org.openqa.selenium.internal.seleniumemulation.FireEvent.handleSeleneseCommand(FireEvent.java:35)
at org.openqa.selenium.internal.seleniumemulation.FireEvent.handleSeleneseCommand(FireEvent.java:1)
at org.openqa.selenium.internal.seleniumemulation.SeleneseCommand.apply(SeleneseCommand.java:33)
at org.openqa.selenium.internal.seleniumemulation.Timer.run(Timer.java:47)
at org.openqa.selenium.WebDriverCommandProcessor.execute(WebDriverCommandProcessor.java:277)
at org.openqa.selenium.WebDriverCommandProcessor.doCommand(WebDriverCommandProcessor.java:209)
at com.thoughtworks.selenium.DefaultSelenium.fireEvent(DefaultSelenium.java:201)
Solution
use selenium.selectWindow
to select popup and then use selenium.selectWindow(null)
to select base window. You didn't describe as which kind of popup it is. Is a confirmation box or a frame or a model dialog or simply another window. selenium differ in treatment of all these
OTHER TIPS
I've found that on some occasions when triggering javascript in particular selenium's click function doesn't invoke the elements onClick command properly and this might be the problem you're encountering.
If so try using the following to explicitly fire the onClick event:
selenium.fire_event("link=Identify Awards", "onClick")
Hope that helps.