css/selenium: visiblity of an element does not change - css

I have an element (text box), which has the following attribute:
style="visibility: hidden;" and style="visibility: visible;"
When this textbox is empty the visibility is visible and vice-verse for when the textbox contains some text.
Now, I have a test-case in selenium where I am trying to get the attribute value of this attribute.
I remove all the text from the textbox and then check the style attribute.
The following wired thing is happening:
1. When i run the test-case and the Firefox window running the test-case is in focus, then the style comes out fine (visible, after removing the text in the textbox)
2. But when that window is not in focus my test-case always fails as the style attribute still shows 'hidden' even though i have removed the text from the text box.
could someone please help with this?
thanks

use this it ll work
selenium.get_eval("element = this.browserbot.findElement('locator'); vis =window.document.defaultView.getComputedStyle(element,null).getPropertyValue('visibility');")

Related

What CSS property is controlling this input highlighting?

The image below shows an input field with the text 'test' in it, immediately after clicking in the input to gain focus:
I'm trying to remove the green highlighting (the green is coming from the OS highlight color). Here is another image illustrating the desired behavior with a normal, unstyled input:
As you can see, the standard behavior is a cursor appearing where the user clicked, as opposed to highlighting the entire text with no cursor. What is causing this behavior?
The styling for this element is scattered all over the place, and inspecting the computed properties doesn't seem to reveal anything unusual to me. This behavior is present in Chrome and Firefox.
It appears something is selecting the text on focus. You could use javascript to collapse the selection on focus.
http://developer.mozilla.org/en-US/docs/Web/API/Selection/collapse

Unable to click on hidden checkbox (Selenium-Webdriver)

I have an issue I cannot resolve by myself.
There's a web page with a check box on it. See scr1.png attached.
The check box is some sort of a decoration ( I don't know what this technology is). I cannot click on it, and Webdriver doesn't see it. Real check box is hidden. It is hidden in CSS file (see right corner of a scr1.png)
Now when I change it manually in FireBug from visibility: none to visibility: yes, then real check box is shown on the page (see screen shot 2).
ISSUE
I'm trying to click on this check box like this:
#driver.find_element(:id,"MainContent_chkAuthorize").click
But then I'm getting Selenium::WebDriver::Error::ElementNotVisibleError: because element is hidden and cannot be found by Webdriver.
Is there any way to overcome this issue?
How can I change the visibility with Webdriver?
How can I click this element at last?
To make checkbox visible you should change its display property.
input.styled{
display:block; // Or you can remove this
}

Web Form Validator Layout Issue

I have a Div that holds a RadioButtonList with 2 values and a required field validator.
As you can see the validator wraps to the next line (Circled). I am trying to get it to display next to the RadioButtonList (where the red dot is). No matter what I do it remains on the next line.
I have made the cell wider with no effect. I have set Display to Dynamic, no effect. With all the other controls on the form (textboxes & Drop downs) the validator displays correctly but this one wont. It is the same in Design mode as it is when I run the app.
On the RadioButtonList I set RepeatDirection to Flow. Its fixed the problem.
I think the size of the div where you place the radio button control is small.Can you please increase the size of that div.

How to hide AspxTextBox?

On a radio button checked event, I hide the div by
document.getElementById("AltYukleniciDiv").style.visibility = 'hidden';
But, when I use it for an aspxTextBox, it doesn't hide it. Or when I use the ClientInstanceName instead of document.getElementById(" ")
UnvanText.SetVisible(false); this didn't work either. UnvanText is ClientInsanceName.
javascript crashes there. I put an allert after that and it never shows it. I have to do it because I hide a div, including everything in it, but it still shows the textboxes that has validation. I don't know how it is possible. Can you tell me a way to hide them all? It used to hide the div with all of its contents before I make some validation settings.
It sounds like asp.net is being 'helpful' and changing the IDs of your elements.
Give the text box the attribute ClientIdMode="Static", and it might fix it.
you can add a CssClass attribute to that text box then use it to find the element and hide it.
You can consider using jQuery, so you need to write a single line of code:
$(".MyHideClass").hide();
or set attribute style display:none
I can advice using Firebug (FF Extension) for debugging javascript

Displaying a note when focus comes over a text box

I want to display a note to the user whenever the focus comes to a particular textbox i have written the note in a div and set its visibility to false what to do next
Instead of your div, put that text into a ToolTip property on the textbox control and ASP.NET will take care of it for you.

Resources