Unable to operate the prompts of spot fire using selenium webdriver - selenium

If anybody has tested spot fire web applications using selenium webdriver please help me. Spot fire uses prompts as popups. And am unable to locate the prompts buttons to click.
Steps i followed:
Save the current window handle.
Get the next prompt window
handle by traversing through iterator(While Loop).
Find the element on new window and click it. But when i printed current
window handle and new window handle are same.
Below is my code
String parentWindowHandler = driver.getWindowHandle();//Stored parent window
String subWindowHandler = null;
Set<String> handles = driver.getWindowHandles();
Iterator<String> iterator = handles.iterator();
while (iterator.hasNext()){
subWindowHandler = iterator.next();
}
driver.switchTo().window(subWindowHandler);
(....My click functions)
I have pasted the fire bug element track below for "OK" Button on prompts.
Next
I have tried to take control using "class" but its throwing exception saying it cant take common/general class.
Please suggest me how to proceed to click a OK button on spot fire prompts.
I forgot to inform.My Prompt contains a "scroll bar" and "Next" button and "Cancel" Button. I need to choose items from scroll bar and press next or cancel button.

Related

Selenium Webdriver - Accessing 2nd Child window(Popup)

I am automating an application in IE where if user clicks a link on the main window , a child window popups. User further clicks another link from the child window where a 2nd child window popsup. Please find the screenshot of the same application screenshot
Problem is that the 3rd popup window is behind the 2nd popup window. with the following code i am able to get the title for the 3rd popup window, but cannot able to work (Like click on any link etc) over there.
Please find below the code which i have used to navigate to 3rd window from the 2nd.
`String Mw1 = driver.getWindowHandle();
//User clicks a radio button on 2nd window
driver.findElement(By.id("CallType-0")).click();
//User click a submit button and after this the 3rd window popsup
driver.findElement(By.id("cmdLogCall")).click();
Set<String> r1=driver.getWindowHandles();
Iterator<String> i2 =r1.iterator();
while (i2.hasNext())
{
String childwindow2 = i2.next();
if(!Mw1.equalsIgnoreCase(childwindow2))
{
driver.switchTo().window(childwindow2);
String z = driver.getTitle();
System.out.println(z);
driver.findElement(By.id("overridelink")).click();
}
}`
Kindly let me know how can i access the 3rd window.Thanks
Use the following code to switch onto the required window
ArrayList<String> allWindows = new ArrayList<String> (driver.getWindowHandles());
driver.switchTo().window(allWindows.get(2));
System.out.println(driver.getTitle());
driver.switchTo().defaultContent();

How to close pop up window, when there is no XPath for close button?

When I clicked on a some link, the popup window is opened on new browser.
I want to close that pop up window, but I am unable to find out the locator.
How to close window, when it is opened as popup in Selenium?
Use this this,it worked for me
// Before new window
String currentWindow=driver.getWindowHandle();
//After window new open
Set<String> handles=driver.getWindowHandles();
//to make set having only one single/current window value
handles.remove(currentWindow);
String[] handlesArray = handles.toArray(new String[handles.size()]);
driver.switchTo().window(handlesArray[0]).close();

Unable to move focus using Action class in selenium webdriver

Hello I am working with popup which are made by
So while I click on one button i.e. "click1" it pops up one div window ..
So on this pop up I can play with element by using action class
WebElement element = wd.findElement(By.className("qx-window"));
Actions actions = new Actions(wd);
actions.moveToElement(element).click().perform();
Now from this popup while i click on another button it again pops up another popup and again I tried with action class but unable to set focus on the new pop up
So scenario is main window->popup->popup
can I able to remove focus from first pop up
Hear below selenium code is not working that's why I use action
for (String popup : wd.getWindowHandles())
{
wd.switchTo().window(popup);
}
Try with below flow
//Store main window handle in one variable
String mainWindowHandle = driver.getWindowHandle();
//click something on window to open popup1
Set<String> windowHandles = driver.getWindowHandles(); //It returns Set of available window handles
//from above set get popup1 handle and switch control to popup1
//==switch control to pop-up1
windowHandles.remove(mainWindowHandle);
String popup1Handle=(String)windowHandles.toArray()[0];
driver.switchTo().window(popup1Handle);
//do your operations in popup1
//===== YOUR ACTIONS GOES HERE FOR POPUP1
//click on button in popup1 which will open popup2
//switch the control to popup2
windowHandles = driver.getWindowHandles(); //It returns Set of available window handles, here it returns 3 window handles
windowHandles.remove(mainWindowHandle);
windowHandles.remove(popup1Handle);
String popup2Handle=(String)windowHandles.toArray()[0];
driver.switchTo().window(popup2Handle);
//do your operations in popup2
//===== YOUR ACTIONS GOES HERE FOR POPUP2
driver.close(); // this will close popup2 as control is in popup2
//switch the control to main window again
driver.switchTo().window(mainWindowHandle);

Getting the name of a button while the progress bar is going on in webdriver

I have one button named "Add" in my web portal. On clicking on that button a progress bar appears and the name of the button gets changed to "Adding" from "Add" and remains "Adding" until the progress bar is not moved to 100%. After the progress bar is 100% complete, again the text of Add button changes back to "Add" from "Adding".
I need to assert whether the name of the button is changing from "Add" to "Adding" or not during the progress bar movement. But the problem is once I click on the "Add" button, then use the assertion, selenium will first click on "Add" button, completes the progress bar to 100% and then tries to assertion, but now already the text of "Add" button is already changed back to "Add" from "Adding".
Please give the solution. Thanks in advance.
You can find the element, click and immediately return it's text which can be used later for Assert
public string Test()
{
IWebElement element = Driver.FindElement(By.CssSelector("Something"));
element.Click();
return element.Text;
}
Assert.IsTrue(Test().Contains("Adding"));
Note: C# code

Keep Popup Window in WebBrowser control instead of a new window

When using the WebBrowser control, is it possible to cause popup windows to
appear within the WebBrowser control itself instead of a new window?
I can't figure out how to get the popup to appear in the same browser window. please help me :)
PS : The language I use is VB
If you have multiple tabs with WebBrowsers, use this under the "New Window" Event:
((WebBrowser)TabControl1.SelectedTab.Controls[0]).Navigate(((WebBrowser)
TabControl1.SelectedTab.Controls[0]).StatusText)
'next input <cancel[IE]>
e.Cancel = True
If just a plain browser put this under the New Window Event:
webBrowser1.Navigate(webBrowser1.StatusText)
e.Cancel = True