Text htmlText and BR tag - flex3

I have some problem with htmlText property into a Text control
<mx:Text id="txtTestoMessaggio" width="100%" htmlText="{contenutMessagge}" condenseWhite="true" styleSheet="{styleHTML}"/>
where contenutMessagge is
<b>test</b><br/>
<br/>
test<br />
<br />
<font color="#FF0000"><br />
red</font>
is showed as
"test test red"
So BR tag are ignored ... why ?
instead of <br/> works !!!

This "html text" is not a real browser - its capabilities are extremely limited. As far as I know, <b>/<i>'s are generally supported.
I'd suggest you give a try on place plain newlines ('\n') instead of <br/>s.

Related

Read the label of a Radio Button and confirm the value with Selenium

So as the title suggests. I am looking to confirm that the value of the Radio button is correct.
The HTML is as follows:
<input type="radio" value="Coach" name="servClass" checked="">
<font face="Arial, Helvetica, sans-serif">
Economy class
<br>
<input type="radio" value="Business" name="servClass">
Business class
<br>
<input type="radio" value="First" name="servClass">
First class
</font>
The selenium bit is as follows:
String expectedServiceClass = "First class";
String actualServiceClass = driver.findElement(By.cssSelector("input[value='First']")).getText();
if (actualserviceClass.equals(expectedServiceClass)){
System.out.println("Correct Wording");
}else{
System.out.println("Oops: somethings not right with the wording");
//close Firefox
driver.close();
// exit the program explicitly
System.exit(0);
}
But when this is executed, the actualServiceClass variable doesn't contain any values i.e. null therefore the "if statement" will always print "Oops: somethings not right with the wording"
Any help???
With the current HTML code, you won't be able to confirm the value of label of Radio button as Radio button is implemented as Input tag, that is a self-closing tag and hence getText() on input will always return null. You will need a container tag like div to include the Input tag(radio button) and the label. Refer: Self-closed versus Container Tags
The problem is not with the Selenium Code, its actually due to the improper HTML snippet. Changing the HTML as below can solve this:
<font face="Arial, Helvetica, sans-serif">
<div>
<input type="radio" value="Coach" name="servClass" checked="">
Economy class
<br>
</div>
<div>
<input type="radio" value="Business" name="servClass">
Business class
<br>
</div>
<div>
<input type="radio" value="First" name="servClass">
First class
</div>
After this, just changing the Css Selector or XPath to find the div will give you value of label of Radio Button. Css Selector can be div>input[value='First']. Let me know if you are able to solve the problem.
I agree with #Manu the HTML snippet is poor but you can use javascript childNodes to get the text from the nodes
The childNodes property returns a collection of a node's child nodes, as a NodeList object.
The nodes in the collection are sorted as they appear in the source code and can be accessed by index numbers. The index starts at 0.
Use executescript to execute JavaScript in the context of the currently selected frame or window
Below is an example in java
Don't forget to add return since you need to return the value to the caller
WebElement element = driver.findElement(By.xpath("//input[#value='Coach']/following-sibling::font"));
String node_text=(String)((JavascriptExecutor)driver).executeScript("return arguments[0].childNodes[0].nodeValue",element);
System.out.println(node_text.trim());
Try the above script it will return "Economy class"
In the above script we use childnode property to get all the childnodes of
font tag <font face="Arial, Helvetica, sans-serif">
similarly you can get the other text nodes by replacing childnode index
childNodes[4]----->"Business class"
childNodes[8]------>"First class"
I tried the above code it was working fine
Hope this helps you...kindly get back if you have any queries

want to gettext from span

I want to get text "Entered code is already exists" using selenium webdriver , I tried using id="code_error" but no use
HTML code is as follows :
<div class="leftsection">
<div class="form-element">
<fieldset>
<label><span class="required">*</span>Code:</label>
<input type="text" maxlength="6" value="" id="code" name="code" style="border: 1px solid rgb(178, 178, 178);">
</fieldset>
<span role="alert" class="errormsg" id="code_error">Entered Code already exists</span>
</div>
i used xpath , id, cssselecor but it returns NULL.
Have a look at the below code..works perfectly
options=driver.find_elements_by_class_name("errormsg")
for i in options:
print i.text
when selenium can parse JavaScript, you can use this:
var text = document.getElementById('sbucode_error').innerHTML;
Please use Selenium Ide to check whether id=code_error selector pointing to your element then use the below mentioned code to get text from that.
driver.findElement(By.id("code_error")).getText();
String text = driver.findElementById("code_error").getText(); should do the trick for you :)

ModX Eform: Captcha not generating image

I am trying to get CAPTCHA working on the eForm plugin. I have added the input form field:
<label for="cfCaptcha">Captcha:<br />
<img src="[+verimageurl+]" alt="verification code"><br />
<input id="vericode" name="vericode" class="text" type="text">
and I have added
&vericode=`1`
to the eForm call.
and have added the Template Variable [+verimageurl+] to my template.
However, when I preview the form all I see in the image area is <img src="" alt="verification code">
Would anyone know what I am doing wrong?
Did you get this fixed?
Check that you ended the label code. Run it through w3c code checker too.
A few times I have left a element un-closed and it breaks the whole thing.

Making asp:Label a specific HTML tag

New to VB.net, just trying to figure out how to properly manipulate the asp:Label control.
I have a page that, based on if there are results, etc should display an <h1></h1> tag with a header, then the data. As I am using the code-behind model, my user facing page essentially just has the following:
<asp:Label ID="lblMessage" runat="server"
Visible="false" />
<asp:DataList ID="dlCurriculumLists" runat="server"
DataSourceID="sdsCurriculumLists"
DataKeyField="Entry No_"
RepeatLayout="Flow"
Visible="false">
<ItemTemplate>
<div>
<asp:HyperLink ID="hlCurriculum" runat="server"
Text='<%# DataBinder.Eval(Container.DataItem, "Title") %>'
NavigateUrl='<%# DataBinder.Eval(Container.DataItem, "File Path") %>'
ToolTip='<%# DataBinder.Eval(Container.DataItem, "Title") %>'
Target="_blank"
Style="font-weight: bold;">
</asp:HyperLink>
</div>
</ItemTemplate>
</asp:DataList>
On my code-behind page, I then set the asp:Label and asp:DataList to Visible="true" based on the data from the database. Here's the catch - if there is data, I want to set lblMessage to be an H1, and if not, just standard Label text. I realize I can emulate the look through the CSS, but was just hoping there was another way (maybe similar to the ItemTemplate concept) to specify the HTML type of the Label control - it appears to be a by default.
For people coming from a VB background, it's a common mistake to think that the most basic control for displaying arbitary text is a Label.
That's not true. A label should label something, usually another UI control (that's what the AssociatedControlId property is for).
If you just want to display arbitrary text or HTML markup, use something more basic instead. Some examples are asp:Literal, asp:Placeholder or asp:Localize.
Using, for example, an asp:Literal called myLiteral, you can easily create a heading in code:
myLiteral.Text = "<h1>" & Server.HtmlEncode(myHeading) & "</h1>"
As far as I know, the asp:Label component will always generate a <label> HTML tag when its AssociatedControlId attribute is set.
What you could do instead is use a Literal Control and populate it with the HTML you wish at runtime.
UPDATE
One thing you could do to make this work as required using your current Label control is to have a theme for the label that marks it up as a H1. You could then toggle the controls EnableTheming property as required.
Aside from what already has been suggested here, you can also implement your own ASP.NET control with any properties you want, then modify its rendering on the fly, depending on the properties' values. It is pretty fun to do and is not as hard as one might think. Here is some information on the subject: http://msdn.microsoft.com/en-us/library/vstudio/zt27tfhy(v=vs.100).aspx

Paste a text to textarea in browser control in Vb.Net

How can I paste a text to the text area within a form in the browser control?
I think how i have selected is correct
browser1.Document.Forms.GetElementsByName("editform").GetElementsByName("input")
UPDATE:Here is the Html
....
<form name="editform">
<textarea name="input">
</textarea>
</form>
...
Here is an example of how it can be done based on the HTML you've provided. You must first add a reference to MSHTML via the Microsoft.mshtml. Also, I would recommed adding an id attribute to the text area then you can get to it much easier. Something along these lines.
<form name="editform">
<textarea id="myTextArea" name="input">
</textarea>
</form>
Then you can set the value property of the text area.
Dim textArea As HTMLTextAreaElement
textArea = WebBrowser1.Document.GetElementById("myTextArea").DomElement
textArea.value = "Hello World!"
Figured out it's not possible due to security reasons.