Anyone please tell me the command to verify whether the option is enabled or disabled using Monkey-talk.
You should be looking at the .enabled property is true or false. Here is an example:
Button login_button Verify 1 .enabled
Button login_button Verify 0 .enabled
Two ways:
Search for the button name in the component tree and see the state whether it is visible / hidden.
If there is a button named "LOGIN", the mt command, "Button LOGIN Verify" will check whether LOGIN button is visible on the screen. If it is visible on the screen, it returns "Completed Script Playback - OK".
If LOGIN button is hidden or not available in the activity, then returns, "FAILURE: Unable to find Button(LOGIN)".
Related
I'm trying to click the 'Allow essential and optional cookies button' which pops up on Facebook.
button = driver.find_element(By.XPATH,"//button[#id='u_0_e_EQ']")
button.click
the error is that the id (u_0_e_EQ) changes every time the page is reloaded. Is there any way to get around this?
If the button label is unique, you can use it.
driver.find_element(By.XPATH,"//button[text()='button_label']").click
I am using selenium with IE to automate web testing. My webpage fills out a form and finally clicks a button. Code to click button is
driver.FindElement(By.CssSelector("td.ne-fieldvalues > input[type=\"button\"]")).Click();
8 out of 10 times, it Clicks but other time click command is never executed.
Is there way I can check if button was indeed clicked ? something similar to checkbox
if (!driver.FindElement(By.CssSelector("input[type=\"checkbox\"]")).Selected)
driver.FindElement(By.CssSelector("input[type=\"checkbox\"]")).Click();
I tried .Displayed and .Enabled and both these properties are always true.
Thanks for help.
To ensure that an action is performed on a click of a link or button, it is best to verify the resultant state of application. For eg. if I click on 'Log in' button after entering valid username and password, it will take me to my homepage, verify that homepage has loaded, else fail the click event. In case of invalid username/password, verify the warning message on login page itself.
To summarize, you have to validate the response to verify click event on any web element.
The least you can do is ensure that the element is clickable using ExpectedConditions.elementToBeClickable():
// In Java
WebDriverWait wait = new WebDriverWait(driver, timeOut);
wait.until(ExpectedConditions.elementToBeClickable(locator));
I have an option group or "frame", and inside I have 4 buttons (Option Buttons).
They are called:
opt_mtto
opt_elec
opt_qlty
opt_complete
So I was selecting the property of each button to Enable = False, so when my form load they will be Disabled. But, I didn't to be coding each button to enable each of the buttons, I though.. why wouldn't be better to say to the frame to be disable, so all inside would be disable.
So instead of going for each button, I return to my properties and enabled them again, but I disable my frame, so this made the same way, but only with 1 click .
But I got a problem, when I click a button I want my frame get enabled so I code:
frame01.enabled = True
(This enabled all my buttons..)
But I only want 1 button Disable, in this case:
opt_mtto.enabled = false
so my code is:
frame01.enabled = true
opt_mtto.enabled = false
and this get me an error: 2101: "The setting you entered isn't valid for this property".
So I made this the other way, I enabled my frame, and then call the option button to be disable, and it works...
I only want to know why, I can't do this, the first way I mention.
I repeat is:
When Form_Load the property are already set to the frame as False (no CODE, is set manually, in properties)
When click button, enable Frame,
Just after of enable the frame, disable one of the buttons inside.
ERROR...
Why
Solution:
The frame was getting focus before disabled the button.
You can't disable controls if they are focus, this wasn't the same case, because the focus was on the frame, not in the button, but it happened the same way, I just needed to re-focus in other place.
I am new to Objective c programming. I have created an application which has a UI with two buttons "Cancel" and "Ok". On clicking "Cancel", the application must terminate and clicking "Ok" must perform some task. Everything works fine. I am able to tab between these buttons and can call the required functionality by clicking space button.
All I want to do is, that when focus is on "Cancel" button(using tab key) then on clicking enter button from keyboard, my application should terminate and similarly, when focus is on "Ok" button then clicking enter should perform the desired functionality.
I have even set the 'setKeyEquivalent" property of the "Ok" and "Cancel" button, but I can only set unique keyequivalents. I also tried to read the title or tag value of the buttons and then call the required functionality but it didn't worked too.
Can someone please guide me how can I use enter button to invoke different functions depending upon the selected button in UI.
I think you don't want to set key equivalents for the buttons. You would want to override keyDown: and test for the enter key, then do the appropriate thing depending on which button had focus (which I think you could determine using NSWindow's firstResponder method).
i am trying to press the ok button from a confirmation box like this (i added Thread.spleep so i checked the button is pressed and the confirmation box is shown)
selenium.chooseOkOnNextConfirmation();
selenium.click("xpath=//a[contains(#href,'123')]");
assertTrue(selenium.getConfirmation().equalsIgnoreCase("123"));
but i get this
com.thoughtworks.selenium.SeleniumException: ERROR: There were no confirmations
at com.thoughtworks.selenium.HttpCommandProcessor.throwAssertionFailureExceptionOrError(HttpCommandProcessor.java:97)
at com.thoughtworks.selenium.HttpCommandProcessor.doCommand(HttpCommandProcessor.java:91)
at com.thoughtworks.selenium.HttpCommandProcessor.getString(HttpCommandProcessor.java:262)
at com.thoughtworks.selenium.DefaultSelenium.getConfirmation(DefaultSelenium.java:429)
Thx for your help.
I got the same error with the code
selenium.chooseCancelOnNextConfirmation();//点击cancel按钮
selenium.click("link=Delete");
selenium.getConfirmation();
Finally I find the reason is that the developer used the jconfirm function of jquery instead of window.confirm, and the jconfirm function is override with div.
Finally I used assertTrue(selenium.isElementPresent("id=popup_container")).
from this information it is hard to say exactly. but i will give you some info which will help you
java script generates 3 types of pop-up windows
1) Alerts
2)Confirmations
3)Prompts
your case, i guess
1) may be the statement selenium.click() you used, is not triggering the confirmation box
OR
2) if it is triggering, then it may not be the Confirmation box.it could be any one of the other 2 boxes
so, you must make sure manually what type of pop-up window it is and call the statements accordingly.
ex : Confirmation window : conatins OK and Cancel buttons
Alert window : contains only OK button
Prompt window : contains Textbox and OK and Cancel buttons
so check and use that commands respectively
if it is not the above case please the HTML code also