Wait for asyncronous event with Selenium IDE - selenium

I have two radio buttons and one text box. Every time I switch the radio button the text box is cleared.
Following sequence:
text box is empty
I switch the radio button (Selenium IDE: click -> radioButton)
I input some text in the text box (Selenium IDE: type -> textBox)
Problem:
The input for text box is done before clear of radio button takes place. So everytime I input something in the text box the input is deleted after a short period of time.
How can I avoid this?

Try adding a "Pause" command after clicking on the radio button
Command: pause
Target: 3000 (or as applicable)
Value:
This way your execution will wait for 3 seconds, and hopefully the text box will be cleared when you get to the "SendKeys" step.
PS. Try using webdriver with your language preference.

Related

selenium, hidden button by overlapped input ( not clickable)

Is there any way on how to click a hidden button by an overlapped input text field, for example if you go to www.google.com and enter a text to search for, selenium can not find the "Search Google" button because it is hidden by the autocomplete of the text field.
Thanks.
You can bypass the validation by using #click! instead of #click. Basically, this triggers the click via JavaScript rather than through standard Selenium commands.
browser = Watir::Browser.new
browser.goto('www.google.com')
browser.text_field(name: 'q').set('watir')
browser.button(name: 'btnK').click!
If you are only using Selenium, you can do:
btn = driver.find_element(name: 'btnK')
driver.execute_script('arguments[0].click();', btn)
As discussed in the comments, you could also close the suggestions box before trying to click the button. You can do this by moving focus to any other element - eg the first link on the page. Depending on what you're testing, this may or may not have value.
browser.text_field(name: 'q').set('watir')
browser.link.focus # move focus to any other element so suggestions close
browser.button(name: 'btnK').click

Using Selenium Ide how to focus on the textbox before or after providing an input?

The field is only activated when I physically click on it or with a Tab. My selenium script can input the value but the system treats it as no entry (ignores entered value). I tried all of the below but the event didn't fire:
sendKeys|xpath|${KEY_TAB}
fireEvent |xpath|focus
focus|xpath|
ClickAt|xpath
sendKeys|xpath|value${KEY_ENTER}
fireEvent | xpath | blur worked for me

Unable to find button of dialog in coded ui test

i have ok button on my dialog box and on the top of dialog new dialog is opening which having again ok button while recording it identify the button but when i run coded ui test then it will not identify second ok button and not clicking on it because of it my test get fail...i am using visual studio 12 ultimate.... please help
Thanks in Advance
Use uielements wait methods WaitForControlExist, WaitForControlEnabled and WaitForControlReady before you click when dealing with popups, or any button. It's likely that your tests are trying to click before the popup "ok" button is ready.
uiControl.WaitForControlExist(20000);
uiControl.WaitForControlEnabled(20000);
uiControl.WaitForControlReady(20000);
mouse.click(uiControl);

Need to change focus to another text box before buttons are activated

I am entering data into text fields in a browser via "type" command. In order for the Save and Cancel buttons to be activated (not grayed out), I need to click in another text field to change focus. This works manually, but I can't seem to figure out how to do it programmatically. I have tried click, clickAt, doubleClick, mouseOver/click/mouseOUt, mouseDown/mouseUp, focus, fireEvent ... all without luck. Thanks for any suggestions!
Does tabbing out of the input field enable the buttons? If so, maybe you can just do:
WebElement element = driver.findElement(By.id("your_input_field"));
element.sendKeys(Keys.TAB);

Selenium - How to click OK button in a pop up using text containing in that button

The code below is shown in firebug for the OK button in the popup of my application
<button id="ext-gen219" class="x-btn-text" type="button">
OK
</button>
Here the button id is randomly generated and also the position of ok button is not identifiable. Is there a way to click on the button by its text? Like the button contains a text called OK.
For Selenium IDE or Selenium RC, xpath=//button[contains(., 'OK')] ought to be a good locator.
I am going on the premise that the text of the popup boxes are not identical so I would recommend something like this:
List<IWebElement> dialogBox = driver.FindElements(By.Class("dialogBoxClass");
int buttonIndex = dialogBox.FindIndex(i => i.FindElement(By.Class("DisplayedTextElementClass").Text.Contains("some unique text here"));
dialogBox[buttonIndex].FindElement(By.ClassName("x-btn-text")).Click();
This captures the parent element of all the dialog boxes and then parses each object to find the index of the box you want and then clicks on the 'Ok' button in the correct object.
In case of a submit button this locator css=input:submit[value="OK"] should work. In case of a button element take css=button:contains("OK").