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

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

Related

How to validate the user has been scroll to top when he click on "back to top" button in selenium

I came across one of the scenario where I need to validate the user is scroll to top of the page when clicked on the "back to top" button on the bottom of the screen.
I tried with the following way but that didn't work.
I tried to validate the element present on the top of the page using
isDisplayed method
I have attached the image for clear description.
Solved it using the javascript concept used pageYOffset method.
Complete code
JavascriptExecutor executor = (JavascriptExecutor) driver;
Long value = (Long) executor.executeScript("return window.pageYOffset;");
pageYOffset method will return the vertical pixels, so as soon I logged in got the vertical pixels and then scrolled to the back to top button and after performing the action on back to top button, again got the vertical pixels and validated it.
isDisplayed() checks if the element is actually present in the viewport so it should work. May be put some wait in between clicking and checking isDisplayed for debugging puropose .
if (element.isDisplayed()) {
doSomething();
}
else {
doSomethingElse();
}

Selecting popup without title and clicking button inside it with geb

I have a popup without title and I want to detect the window using any other criteria (for example a div that wraps the whole popup) and click a button inside it.
I've tried the following:
when:
withWindow({ $("div", class:"main.msgAlert" )}) {
$('#close').click()
}
then: true
But I always get a org.openqa.selenium.ElementNotVisibleException at te #close action.
Am I failing at detecting the window or is the error related to the button?

Unable to operate the prompts of spot fire using selenium webdriver

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.

Tool Tip obscures button

I want to pop up a tool tip when mouse moves over button, to explain what will happen if the user clicks on the button.
This code seems to do the job ( except for a big snag )
wxHelpProvider::Set(new wxSimpleHelpProvider);
...
btnDisplay = new wxButton( this, -1,
"DISPLAY", wxPoint(10,35));
btnDisplay->SetHelpText("Click to display this dimension");
btnDisplay->Bind( wxEVT_ENTER_WINDOW, &cHiddenDimensionPanel::OnDisplayHelp, this );
...
void cHiddenDimensionPanel::OnDisplayHelp(wxMouseEvent& event)
{
wxHelpProvider::Get()->ShowHelp((wxWindowBase*)event.GetEventObject());
}
The snag is that the tooltip obscures the button! If I click on it, the tool tip vanishes for a moment, but immediately pops back up. It is not possible to click the button under the tooltip.
You should be using the SetToolTip(const wxString &tipString) method, and letting wx handle showing/hiding the tooltip - not re-appropriating the HelpText property and manually managing the tooltip display.

Weird behavior of GWTP app when hitting "Go Back" and "Go Forward" button of Web Browser?

I am using GWTP and I found this issue.
I have this code in CustPresenter:
private List<String> dataList=new List<String>();
#Ovvrride
public onBind(){
myTextBox.setText("Test");
dataList.add("test");
}
Ok, now first time opening the page, the page show the textbox has string "Text" & the dataList has "test" value. While on that page, I hit the "Go Back" and "Go Forward" button of Web Browser (like Chrome or IE). When click "Go Back", then of cause it will show the previous page. When clicking "Go Forward" it will show the customer page & I still see the string "Text" in the textbox of customer page, but dataList has no "test" value?
What is happening?
Is it a bug of GWTP or did i do anything wrong?
Note: I am using GWT 2.50 Last year version
the onBind() method is only called once, when you first instantiate the Presenter. So it populates the TextBox and dataList as you want.
Then when you click back and go forward again what you are seeing is the View that was populated by the first call to onBind(). Pressing forward does not run onBind() again so maybe you are re-instantiating the ArrayList somehow and then NOT populating it because onBind() has already been called.
Try this:
#Override
public onBind(){
private List<String> dataList = new ArrayList<String>();
myTextBox.setText("Test");
dataList.add("test");
}
Or just change onBind() to onReset() or onReveal(), as those methods get called whenever a presenter is revealed.
Someone more knowledgeable may want to correct me here though.