HTMLUnit click() on HtmlElement does not work - htmlunit

I'm trying to get HTMLUnit to perform a click action on a span, which doesn't work for some reason. Please take a peek at the code below.
HtmlElement clickable = (HtmlElement) page.getByXPath("//div[10]/div/div/span").get(0);
clickable.click();
By doing this I get a really long error message. The interesting bit seems to be the following:
TypeError: Cannot find function setCapture in object [object].(script in [some long url here])
The same thing happens when i try to call on mouseDown() or dblClick() or any other mousey method. This is really frustrating since the code snippet is something that worked fine some time ago. I simply uncommented it today and now it won't co-operate.

HtmlUnit doesn't currently support .setCapture()/.releaseCapture(), please open a bug report in its tracker

Related

Cypress and find the element programatically, but its there and the UI can select it

I am having issues get'ing a css selector, its on the dom, and it can even be selected via the UI.
But cypress fails to get it.
There is not async stuff going on, just the page that was loaded.
As you can see in the image thelement is there, any ideas how to get round this?
If you say that the problem is with loading the page, maybe you should pass timeout paramater to the cy.get(), to make sure that Cypress waits long enough.
cy.get('nli-block-container .block-content', {timeout: 20000})
This should wait for 20 seconds for the element. If that doesn't work, please let me know, because it means that the problem lies elsewhere

Wicket replacing panel with ajax fails with MarkupNotFoundException

the page markup has
<div wicket:id="stepPanel" />
tag in it and when the page is first loaded it works great that is
add(new MyFirstPanel("stepPanel"));
works fine. But then when I trigger an Ajax event and request redrawing
addOrReplace(new MySecondPanel("stepPanel"));
target.add(MyPage.this);
i get the following error
Last cause: Failed to find markup file associated. MyFirstPanel: [MyFirstPanel [Component id = stepPanel]]
please note that it tries to find the wrong markup (should look for markup for MySecondPanel) and it fails regardless it succedded to do so before!
I instantiate panels using reflection, but could it be a problem here? No exceptions thrown.
Anwser:
Actually it was something else - I have noticed that one of my AjaxSubmitLinks had reference to a form that was no longer placed in a markup... so whatever you do just remember not to leave that reference.
You are adding MyPage after replacing the Panel causing MyPage to re-render.
There is a good example on how to replace panels here.
Yes you can call panels via reflection. I don't clearly know what you are trying to do with event here but if you want you can attach your panel with AjaxSelfUpdatingTimerBehavior and define the duration which will update this component in the given time period.
Hope its useful.

kendo grid works fine when javaScript alert exist but not working without javaScript alert

When I add a new row kendo ui grid it does not move to next page even I set page number dynamically.
But when there is a javaScrip alert it's working fine.
Has any one faced this issue before. Please suggest me a solution.
Thank you.
The problem is that when you add a new row there are a series of actions that happen in parallel and they are not immediate. If you try to move to the end but the row still is being created, if fails.
When you add an alert, you delay the fact of moving and creation now have time.
If you really need to do it, you can add a timeout (delay) it is not nice/clean but should work.
Do something like:
setTimeout(function() {
grid.page(3);
}, 500);
for introducing half second (500 ms) delay, should be enough.
We had sort of similar issue in IE - onchange fired twice with alert in the event handler. According to what you saying, it sounds like when the alert is NOT in you are getting correct behaviour. Review your code without having the alert in or post a fiddle. Below is an answer from Kendo support in regards to alerts while debugging. Do not use alerts with kendo to stay safe.
Basically this behavior is caused by using "alert" method for debugging purposes - please note that this is not recommended because it can lead to unexpected behavior when interacting with focusing elements. After replacing the "alert" method and with "debbuger" command or "console.log()" function the change event is working as expected - please check this screencast(http://screencast.com/t/7qIAdK6hZ5kD).
Hope it helps.

Firefox WebDriver does not find the element of the page

I would like to use WebDriver (Firefox) to test my webpage, but I always get this message:
Unable to locate element: {"method":"xpath","selector":"//li[#id='something_spicy']"}
But, the really strange thing is that if I copy the element locator "//li[#id='something_spicy']" and paste it into Firefinder then it works. Basically, I ran out of thoughts about what could be the root cause.
I use C# and here is the code:
movedElement = driver.FindElement(By.XPath("//li[#id='" + originalOrderOfSportContainers[1] + "']"));
Did I do something wrong? Have I missed something?
provide a snippet of the html code of your page.
There is a chance that element is not there immediately after the page is loaded,
but appears a bit later as a result of some javascript function execution.
If this is the case, use explicit wait to wait for element to appear before using it.

firebug fails to report error like "if(maxi - 1 = i)..."

I missed a "=",
should be:
if(maxi - 1 == i)...
but firebug didn't report anything.
And it took quite a while for me to found it.
Is it a bug of firebug?
It works perfectly for me. I am using Firebug v1.4.2.
Additional add-ons: Google Page Speed, YSlow, Firecookies
My code:
<script type="text/javascript">
var max = 5;
if(max - 1 = 4){
alert(true);
}
</script>
Screenshot:
screenshot http://img12.imageshack.us/img12/451/21986504.th.jpg
I have a "Invalid assignment left-hand side" error for the example you've provided.
EDIT:
As described by Asker - the error was in a JS file. I've done an include like this. Same thing, the error was also tracked.
screenshot http://img17.imageshack.us/img17/8462/31594029.th.jpg
Conclusion
I think its that, when you load the page, Firebug is not activated. When you activate after page has loaded, the error was not captured. Thus you see no error. If you keep Firebug activated and open the page, you might just see the error logged.
Hope this helps!
Firebug is not necessarily the be-all-end-all of code problems. It is only a tool to help you find bugs. It's impossible to write a tool to find every single bug in a program (if only...).
To be fair, nothing in your toolbox found it -- why place the blame only on Firebug? You missed it, your text editor missed it, and your unit tests missed it, at least.
For example, if I type that expression in my editor, it's underlined in orange, and the status bar says:
Test for equality (==) mistyped as assignment (=)? (parenthesize to suppress warning)
Why wait until your code gets to your web browser to see if it worked? There are many steps before that which are great for verification and testing. The sooner you identify problems, the easier they are to fix.

Resources