When I activate a url via Webdrive that start up a Word Document a dialogbox with a Yes or No is started up .
How do I send in keys to click the Yes-button in Webdrive.
First you need to switch to the particular window using the following method -
WebDriver.switchTo().window()
If the name is not known, you can use
WebDriver.getWindowHandles()
to obtain a list of known windows. You may pass the handle to
switchTo().window().
If it's JavaScript you can use -
// Get a handle to the open alert, prompt or confirmation
Alert alert = driver.switchTo().alert();
// Get the text of the alert or prompt
alert.getText();
// And acknowledge the alert (equivalent to clicking "OK")
alert.accept();
Hope this helps!
Related
I am working on a GUI project over here, my issue is related with disabling a submit button. The GUI is a Wizard and in some pages, there would be more than one Submit Buttons.
Whenever the user clicks on any of the Submit Button, some verifications will be done and if everything is good the next Input box will be enabled (as it is disabled by default in the XAML). when the user changes the text of the second Input Box, its Submit Button allocated for this Input Box will be enabled.
To make sure the user will not do something wrong, I want to disable the first Submit Button when the user changes the text of the second input box.
At this point, Whenever the user changes the text of an input box, the corresponding submits button gets enabled fine with no issues but the previous submit button do not get disabled.
Below is a PIC of one of the pages and as you can see the second submit button get enabled but the first did not get disabled.
My code is as follow:
# Main Page Input Boxes.
# Enable Submit Buttons.
$Global:GuiHash.WizardMainPageInputBox1.Add_TextChanged({$Global:GuiHash.WizardMainPageSubmitButton1.IsEnabled="True"})
$Global:GuiHash.WizardMainPageInputBox2.Add_TextChanged({$Global:GuiHash.WizardMainPageSubmitButton2.IsEnabled="True"})
$Global:GuiHash.WizardMainPageInputBox3.Add_TextChanged({$Global:GuiHash.WizardMainPageSubmitButton3.IsEnabled="True"})
# Clear default text from the box and disable priviouse submit buttons.
$Global:GuiHash.WizardMainPageInputBox1.Add_GotFocus({If ($Global:GuiHash.WizardMainPageInputBox1.Text -eq "NSX Manager FQDN:") {$Global:GuiHash.WizardMainPageInputBox1.Dispatcher.Invoke([action]{$Global:GuiHash.WizardMainPageInputBox1.Text = ""})}})
$Global:GuiHash.WizardMainPageInputBox2.Add_GotFocus({
Wait-Debugger
If ($Global:GuiHash.WizardMainPageInputBox2.Text -eq "NSX Manager Admin Password:") {$Global:GuiHash.WizardMainPageInputBox2.Dispatcher.Invoke([action]{$Global:GuiHash.WizardMainPageInputBox2.Text = ""})}
$Global:GuiHash.WizardMainPageSubmitButton1.IsEnabled="False"
})
$Global:GuiHash.WizardMainPageInputBox3.Add_GotFocus({If ($Global:GuiHash.WizardMainPageInputBox3.Text -eq "Output folder path:") {$Global:GuiHash.WizardMainPageInputBox3.Dispatcher.Invoke([action]{$Global:GuiHash.WizardMainPageInputBox3.Text = ""}); $Global:GuiHash.WizardMainPageSubmitButton2.IsEnabled= "False"}})
When I try to debug this using debug-runspace, I do not get any error on the line of code where it should disable the submit button.
Line of Code to disable the submit button:
$Global:GuiHash.WizardMainPageSubmitButton1.IsEnabled="False"
Debug Runspaces:
PS C:\Users\Administrator> Debug-Runspace Runspace11
Debugging Runspace: Runspace11
To end the debugging session type the 'Detach' command at the debugger prompt, or type 'Ctrl+C' otherwise.
Stopped at: If ($Global:GuiHash.WizardMainPageInputBox2.Text -eq "NSX Manager Admin Password:") {$Global:GuiHash.WizardMainPageInputBox2.Dispatcher.Invoke([action]{$Global:GuiHash.WizardMainPageInputBox2.Text = ""})}
[DBG]: [Process:7116]: [Runspace11]: PS C:\Users\Administrator>>
Stopped at: If ($Global:GuiHash.WizardMainPageInputBox2.Text -eq "NSX Manager Admin Password:") {$Global:GuiHash.WizardMainPageInputBox2.Dispatcher.Invoke([action]{$Global:GuiHash.WizardMainPageInputBox2.Text = ""})}
[DBG]: [Process:7116]: [Runspace11]: PS C:\Users\Administrator>>
Stopped at: $Global:GuiHash.WizardMainPageSubmitButton1.IsEnabled="False"
[DBG]: [Process:7116]: [Runspace11]: PS C:\Users\Administrator>>
Stopped at: })
[DBG]: [Process:7116]: [Runspace11]: PS C:\Users\Administrator>>
Thanks to Ed Plunkett, based on his comment I need to use the false statement $False instead of using a string. changin my code to the below works like charm. Thank you Ed.
$Global:GuiHash.WizardMainPageSubmitButton1.IsEnabled=$False
I want a toastbar that should display a message to the user before calling a service and hides it after getting the service response.How can I do this??I mean i dont need the expire time to hide it .It should be hidden only after getting the service response.
You can create a ToastBar.Status and show/dispose it manually:
ToastBar.Status s = ToastBar.getInstance().createStatus();
s.setIcon(FontImage.createMaterial(icon, stl, 4));
s.setMessage(msg);
s.setExpires(-1);
s.show();
When you are done with this just call s.clear().
I want to show a Feed back message in sales force Standard page on custom button click using visual force page on the basis of Apex class logic.Any one who can help me?For example if some thing successfully done then success message and if not error message should display on standard page.
You can create a new method to handle your messages
private void displayFeedback(ApexPages.Severity msgType, String message)
{
ApexPages.Message msg = new ApexPages.Message(msgType, message);
ApexPages.addMessage(msg);
}
Build your message you want to show..
displayFeedback(ApexPages.Severity.Error, String.valueOf(TripProfileHandlerServices.ERROR_SAVING_DATA + missingDataError));
Put this message in your VF page
<apex:pageMessages id="feedback" />
You will also have to rerender='feedback" when you want show the message after an event
If you put a <apex:messages /> in the page, you can use the message class to fill it up.
(Sign In) this is the html tag of yahoo sign in. I want to click on the sign in using selenium web driver, and also get the value which is in the title="sign in"? can anyone solve my problem please.
WebElement el = driver.findElement(By.cssSelector(".social-enabled-txt"));
String elementValue = el.getText(); //This one gets the value
el.click(); // This one clicks on the signin button on yahoo.com homepage.
If you want to click on the yahoo sign-in link using the selenium web driver and want to get the value in the title = "sign", the Below code has been given.
driver.get("https://in.search.yahoo.com/?fr2=inr");
//get the text of title in sign in
String text = driver.findElement(By.className("text")).getText();
// Print the title of value
System.out.println("Title of sign in button is : "+text);
//click on sign in link using xpath
driver.findElement(By.xpath("//*[#id=\"ysignin\"]/div")).click();
I'm writing a Silverlight 4 application using "Silverlight 4 Unleashed" as a foundation.
I have a ChildWindow for loggin in with Username, Password, and Remember Me. The OK button is tied to my AuthUserViewModel SignIn using RelayCommand.
Since I'm just starting, I don't have any data validation yet and noticed something weird.
If I click "OK" on my Login child window, my Action callback tells me I have invalid credentials in a MessageBox...which is perfect. I'm using my own Authentication service for various reasons.
However, if I click "OK" again, my service gets called once, but the Action callback is fired twice, telling me I have invalid credentials. If I press "OK" again, the service is called once, but the Action callback is fired three times, and so on and so on.
Why would it be doing that?
Here is the offending code:
public void SignIn(AuthUserDataModel authUser, Action<ErrorContainer> callback)
{
EnsureClient();
client.SignInCompleted += (sender, result) =>
callback(new ErrorContainer
{
AsyncException = result.Error,
CustomError = result.Result.CustomMessage //holds "Invalid credentials"
});
client.SignInAsync(authUser);
}
Like I said, the button event is fired once, the web service is called once, but the callback is fired an amount equaling the number of times I press OK.
Thank you.
Ah! your client object is a field, and you ensured that it is shared across calls. It prevent it from being initialized on each SignIn call, but each time you add an handler to the SignInCompleted vent before executing the SignInAsyncFunction.
Therefore it's normal that the handler gets executed one time by subsequent SignIn.
To prevent this, you have 2 approaches:
1) create a new client in each SignIn call (it will be garbage collected later)
2) attach your handler when you initialize the client.
ie in your EnsureClient, you should have something like:
if(client == null)
{
client = new MyClient();
client.SignInCompleted +=(sender,result) =>{...};
}
and in the SignIn function:
EnsureClient();
client.SignInAsync(authUser);