Any new arrangement for select_list in WATIR 6.0.2 waits until options got populated? - watir

I have a question about select_list which got populated in run time according to the option of some other select list.
For an example If I choose motor car make in my select_list, then model select_list got populated. but the problem is, I have to wait for few seconds before I interact with model select_list otherwise it throws the error no options present(because it takes some time to populate). I find very interesting thing in WATIR 6.0.2 like
b.link(:id,'NewContactNewGenFromMenu_Link').wait_until(&:visible?).click
which first confirm the element present through implicit wait using when_present, then it waits until element visible, this is amazing change. But Is there anything to check whether select list options got populated? Is any new arrangement?

It looks like there is no change to the Select#select method in Watir 6.0.2 - ie it does not wait:
browser.select_list.select('changed_text')
#=> Watir::Exception::NoValueFoundException
You can get an implicit wait if you locate/select the option directly:
browser.select_list.option(text: 'changed_text').select
I think the wait functionality should be added to the #select and #select_value methods. I have opened Issue 503 to request the functionality.

Related

How to click on ::before element (groovy, JMeter)?

I work on client-side in JMeter with groovy and have this situation:
To make SUBMIT button active, I just need to emulate checking this checkbox on previous step in the script.
Could you please let me know, what are the ways to point to / switch on this checkbox, using this ::before element?
Neither
//input[#class='checkbox' and #name='Information']
wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//input[#class='checkbox' and #name='Information']")));
WebElement checkbox_Information = driver.findElement(By.xpath("//input[#class='checkbox' and #name='Information']"));
checkbox_Information.click();
nor
//label[#class='checkbox-label' and #for='Information']"
could help - in both cases here are error messages, for example:
Response message:javax.script.ScriptException: javax.script.ScriptException: org.openqa.selenium.TimeoutException: Expected condition failed: waiting for element to be clickable: By.xpath: //input[#class='checkbox' and #name='Information'] (tried for 30 second(s) with 500 milliseconds interval)
The chance of getting a comprehensive response will be much hire if you:
Don't post code as an image
Provide these "errors messages"
Show (at least partially) your code
So far if you're talking about JMeter's WebDriver Sampler you can try:
Ensuring that the checkbox is visible, not covered by popups and clickable
Usu an Explicit Wait to ensure that the checkbox can be interacted with
And if nothing helps as the last resort you can "click" the checkbox using JavaScript, something like:
WDS.browser.executeScript('document.getElementById("Information").click();')

How to avoid pop-up appearing for a second randomly on different pages

I write UI tests using Selenium Webdriver 2.0 with Python 3.6. A popup appears randomly, that causes focus to be lost, causing my test to fail. It appears for one second, randomly on different pages, and doesn't exist in the DOM, how to win it?
What I've tried:
Try/except
Wait for element
Sometimes these methods help but it's unreal to add it on every step to wait or catch that element
I expect my tests shouldn't fail because of that popup.
here it is

Double number of items returned by Desktop.ChildObjects

I am trying to get all the open Browser objects using QTP11.
The code I use is the following:
Set descBrowser = Description.Create
descBrowser("micClass").Value = "Browser"
Set objChildren = Desktop.ChildObjects( descBrowser )
During testing, i have two IE Browser windows open, but the collection returned by the code shows four found items. I checked the running processes also, which show the correct number of 2 processes running.
I have also checked with 3 Browsers open, in which case it shows 6 objects matching the descrption.
Can anybody explain why this could be happening?
UFT 11.52 + Win7
I had tried several strategies to get this done(PIDs, Title, HWND, browser(index)), and still not success, I am not sure on whether this patch is already there.
What I can picture is that for a simple closing task the UFT is also having issues as it says "Object not visible" when I try to close the Browser() object crashing down the test in random fashion.
The best result was a bunch of already alive IExplorer windows(Tabs) oppened.
Can someone provide steps to check the installed patches ?
I see the same behaviour (only for IE not Firefox).
A workaround for this can be to filter out duplicates. For IE if you compare the objChildren(i).GetROProperty("hwnd") you can filter out those with the same value but this will not work if you also use Firefox since in Firefox if you have multiple tabs they all have the same hwnd.
If you have to take FF into consideration you can filter out duplicates using the CreationTime property (instead of the hwnd).
I had the same issue and I had to back out patch QTPWEB_00090 to get it to work. See if you have that QTP patch installed and back it out.
This is fixed in QTPWEB_00107 - Web Browser Control Recognition in Windows Explorer

Capybara Cucumber test fail to find xpath when browser is minimized

I'm running a scenario where form fields are automatically filled in with invalid values which trigger some javascripts to show warnings under each incorrectly filled field when I blur.
The test passes when the browser is in focus. It finds the xpath with the "expected warning" that I pass. But if I minimize or just click on another application, it fails to find the xpath.
I'm running Firefox 3.6 (going to update it soon) and the way I'm doing to find the xpath is by using "page.should have_xpath(xpath)"
Does anyone have any idea how what might solve this? It's really important for me to run it with the browser minimized.
Edit and alternative solution:
I guess the timing issue that occurs in events such as blur followed by finding a certain xpath in a minimized browser inherent to the driver itself. Therefore, I decided to run the tests in a Virtual Frame Buffer using xvfb in Linux and it seems to be working really well. I'm planning on applying this to be triggered by Hudson/Jenkins whenever a change is committed.
Could it be a timing issue? Perhaps if the browser isn't frontmost and maximised, the rendering is not happening quickly enough for the content be present when Capybara checks for it.
Also: How are you triggering the blur event?

How to use Geb to check element attribute value after page event

After a bit of help here, I am writing a functional web test using Geb and want to test the disabled attribute value of an form submit button both before and after an event has occurred, the flow should be as follows:
Load page, submit button is declared as disabled in page source so should be disabled e.g. <input type="submit" class="submit" disabled="true"/>.
Check a checkbox on the page, this should result in a piece of JQuery code executing which will enable the disabled submit button programatically using: $('input.submit').attr('disabled', false);
My first attempt was to use the assertion $('input.submit').#disabled == 'true', this appeared to work for the initial check after page load however after executing my JQuery code to enable the button a subsequent check still returns the same result. This has caused me to wonder if this kind of check is only able to report the value at page load time and doesn't see any subsequent programmatic changes?
I then discovered Geb's jquery itegration, I was hoping I could use this to return the value of the submit button and do my assert on this e.g. $('input.submit').jquery.attr('disabled') == false however the Geb documentation confirms that all calls to the .jquery property return the Geb Navigator instance so sadly I don't think I can return the information I want.
I have also doubted whether the JQuery code was actually toggling the submit button disabled state, I have tested this extensively using Firebug and can confirm that this is working perfectly in the browser, so I suspect this is either an issue with my understanding of Geb or perhaps a limitation of Geb itself?
It strikes me that checking the value of element attributes after performing some action on a page might be a common use-case, hence I'm rather hoping that I've missed some trivially simple way of doing this. Would be most grateful for any pointers to help me get this sorted.
Cheers,
Edd
Have done a bit more testing and have now achieved a satisfactory result. I was doing a couple of things which I now believe are inproper, namely trying to set the disabled attribute value to illegal values of true and false like this:
$('input.submit').attr('disabled', true);
$('input.submit').attr('disabled', false);
Looking at the HTML forms specification the disabled attribute is shown not to take a value, rather it's presence alone indicates that an element is disabled. Modifying my code to honour this and remove the attribute to indicate enablement of an element seems to have done the trick:
$('input.submit').attr('disabled', true);
//This time we remove the disabled attribute rather than setting it to false.
$('input.submit').removeAttr('disabled');
Note: I am still setting the value of disabled to true since I can't determine how to set the attribute without setting a value, see this SO post for further details.
Using the above I am now able to use Geb to assert the disabled/ enabled status of elements like this:
//Check that something is disabled.
deleteSelectedButton.#disabled == 'true'
//Check that something is enabled.
deleteSelectedButton.#disabled == 'false'
Note: Geb seems to require a string literal indicating the expected status rather than a boolean, which iirc caused my assertions to fail.
So that's it - all is now working nicely and I'm running along writing loads of Geb tests! Hope this explanation is of some use to others.
Rebroadcasting my post on the Geb mailing list:
After you execute the jQuery code that enables the button, is it possible that you are checking the result before the code has actually enabled the button? For example, are doing something like:
waitFor { $("input.submit").#disabled == "false" }

Resources