This is a migrated thread and some comments may be shown as answers.

CSS OnHover

3 Answers 113 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Martin
Top achievements
Rank 1
Martin asked on 25 Apr 2012, 01:49 PM
Hi

Is there a nice way to trigger CSS OnHover?, without actually using the methods which move the mouse.

Thinking of something along the lines of .InvokeEvent(ScriptType.MouseOver)

3 Answers, 1 is accepted

Sort by
0
Cody
Telerik team
answered on 30 Apr 2012, 06:34 PM
Hello Martin ,

I apologize for the delay getting back to you. We have documented this here. You can try something like this:

HtmlButton b = Find.ById<HtmlButton>("b");
 
// Invoke the event.
b.InvokeEvent(ScriptEventType.OnMouseOver);


Regards,
Cody
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Martin
Top achievements
Rank 1
answered on 01 May 2012, 06:44 AM
Maybe i didn't make my self clear.

the invoke script is something i know of and use alot, but that doesn't cut it in this case since there's no java OnHover on the element, only a CSS.

So I was looking for an alternative which will work on a locked screen, but i think i can assume that it doesn't exist then?

Regards 
Martin
0
Cody
Telerik team
answered on 01 May 2012, 06:40 PM
Hi Martin,

I wonder if there's some confusion on how CSS works. CSS is like a template. It defines what attributes to apply to the elements contained in your HTML document. CSS is a way of applying styles and attributes to elements.

You do not "invoke CSS" (that would be like invoking the definition of a word contained in a dictionary). CSS can add JavaScript to elements that cause things like menu drop down on mouse hover over. The CSS is still always applied to the elements that the CSS targets via the CSS selector(s).

Thus your question "Is there a nice way to trigger CSS OnHover?" really only applies to the element the CSS is targeting. You can only invoke the JavaScript that gets attached to an element via the CSS. Is there any other way? No. Again since CSS is only a template, the JavaScript contained in the CSS cannot be invoked directly.

However if the CSS is used to run a separate concrete JavaScript function (i.e. something not contained in the CSS), such as an "OpenMenU" function then yes you can certainly manually execute any arbitrary JavaScript. The key question is what is the function to be invoked. Since the name of the function is left to the web developer, only your web developer would know the name of the function needed to be invoked.

Regards,
Cody
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
Tags
General Discussions
Asked by
Martin
Top achievements
Rank 1
Answers by
Cody
Telerik team
Martin
Top achievements
Rank 1
Share this question
or