I have started testing my UI using qUnit, so I need to simulate some user interaction. Is it possible to "simulate" a user clicking a checkbox using javascript ?
Thx guyes. I figured it out about two seconds after I posted the question. It was as you say simpler than I had imagined
document.getElementById('cb1').click();
did the trick
Edit: It seems in IE7 (and perhaps other browsers) the the click method will not actually check the checkbox. So to fully simulate you need to "check" the checkbox before clicking it
document.getElementById('cb1').checked=true
document.getElementById('cb1').click();
You can look at this:
Simulate a buttonclick via javascript
It is the other way arround, so i'm not sure if it works on checkboxes too.
Related
This is not really question, but just sharing my experience.
I am testing a page containing charts. Whenever a hover action by mouse is done, it shows small hint next to it. This work perfectly interacting with the element manually. The problem happens when trying to hover over element from Selenium.
I tested it with the following code, but it did not work
new Actions(getDriver()).moveToElement(graphElement).build().perform();
It only works if the folowing code is executed prior to using Actions
graphElement.click();
Even though the Actions click() method does not work. It really needs to be clicked through WebElement.click() and then use Actions...
Does anyone have similar experience with this behaviour? Why does the element should be clicked on before the Actions can work?
Because it is in contrary with the flow. Why anyone would start with clicking on the element to check that some message is displayed on hover action?
JS workaround (hover) does not help as well.
Thanks for your posts.
I just searched and found very neat solution.
Using the following code solved that problem with focus.
graphElement.sendKeys("");
so the final version
graphElement.sendKeys("");
new Actions(getDriver()).moveToElement(graphElement).build().perform();
Tab Order in Visual Studio does not work for me for some reason.
I am making a VB.NET plugin for a cad program called Rhinocreos 5.
I have everything set perfect, and I don't know what the cause of it is.
I am using .Show() instead of .ShowDialog(), because I need that thread open and I don't feel like doing any thread management (not paid enough lol)
Does anyone have any pointers for this? Has anyone else ran into a tab problem with Rhino5 and .NET?
EDIT**
Seems I have to use a MODELESS Form for a rhino plugin.... So I wont have any tab keys or arrow keys unless I do a hook. But since I need to make the plugin future proof (in case I am no longer working here), I won't be doing that either. But thanks for the answers, comments, and awesome downvotes.
Very difficult to guess what's going on from the information you have provided, but I'd check the following things in the following order:
The disobedient form is open and has focus.
The form has controls in it.
At least some of the controls are enabled, focusable have their TabStop set to true.
There is no low-level keyboard handling in action (PreviewKeyDown, hooks etc).
Finally I'd call ShowDialog() instead of Show(), passing main form as parameter (to make disobedient form a child of main form) and see if that makes a difference.
It was a modeless form inside of Rhino3D as a plugin.
Rhino3D uses all plugins in the main thread. So tab is not an option.
The workaround was to tag all controls with a tag work (I used "tabMe")
Then I store all the controls in a List myTabbyControls.
Each time I press tab, I would cycle through the list.
But thanks for the down votes. It's the running joke of SO.
Ok! Here is the situation I have a application using Webbrowser Control, I want to detect the click events for anchors in web page. I dont need code, just the directions to look into.
Edit
I didn't find any solution for the problem but found a hack in Control.ModifierKeys, this works until now!
[WebBrowserNavigatingEventArgs][1]
http://msdn.microsoft.com/en-US/library/system.windows.forms.webbrowser.objectforscripting.aspx
I want to write code to log onto an Internet account and also click buttons to navigate to do different things such as watch for something to change. for example I would like
log on to account
click to navigate
while(until I say to stop)
watch for changes
You may look at
http://watij.com/
For automated website tests you can use Selenium.
You might not need to write code - if you use FireFox, perhaps try the iMacros addon?
You've not said what language you want to write this in -- for .NET there's http://watin.org/
Is there a built in method for checking that an input text element has a focus ?
Well, I didn't find one, so I tried this extension.
But, it doesn't work for me either (i.e. the test fails).
Any ideas ?
I have had numerous problems detecting if an element has focus because the browser Selenium is controlling typically does not have the focus within the Operating System, and as such the browser will NOT consider any elements to have focus until the browser regains the focus.
I have been pulling my hair out over this, so worked up a solution to this problem. See http://blog.mattheworiordan.com/post/9308775285/testing-focus-with-jquery-and-selenium-or
for a full explanation of the problem and a solution to this.
If you can't be arsed to read the lengthy explanation, simply include https://gist.github.com/1166821 BEFORE you include JQuery, and use $(':focus') to find the element that has focus, or .is(':focus') to check if an element has focus.
I wrote that plugin and it is working fine in my environment.
Could you provide me a detailed description of how you used it? I would try bugfix it if we will find a bug.