i want to put alt for the imageButton.
this is my code:
CHtml::imageButton($src.'flag.png', array('width'=>'40px', 'height'=>'40px','name'=>'fjfhjf' ,'alt'=>'dfffffffff'));
the answer is use title attribute in the html options array.
Related
I'm trying to insert text into a textarea with a wysiwyg editor (summernote) from a form, i'm using behat featurecontext file for this. The textarea doesn't have a id tag so i need to select the class using javascript code:
document.getElementsByClassName('note-editing-area').item(0).innerText="something"
But when i do this, also the innerhtml is overwritten with the text from innerText.
Any suggestions?
Best way is to set an id or class and select that. If you do not use that it is way more difficult to maintain. You could add this through twig:
{{ form_widget(form.task, {'attr': {'class': 'task_field'}}) }}
Hi
I am not able to find the correct xpath for the Html code added in the attachment.
I have written below xpath but it is not working.
//div[#class="calendar-item-title"][1]//*[#class="calendar-item-time"][1]
Please find attached image for more details of Html code.
div[#class="calendar-item-title"] does not have a child *[#class="calendar-item-time"] according to your image.
Your *[#class="calendar-item-time"] is in div[#class="items-container"]
so your xpath would be:
//div[#class="items-container"][1]//a[#class="calendar-item-time"][1]
Just add : "/parent::*" at the end of //div[#class="calendar-item-title"] if you want the parent element
Try this xpath :
//a[contains(text(),'12:30 am')]
try with the below xpath
driver.findElement(By.xpath("//a[text()='12:30 am']")).click()
from ur image, its not clear there are more 12.30 containing text or not. In that case, use
driver.findElements(By.xpath("//a[text()='12:30 am']")).get(0).click();
I got something like this:
<div id=soandso>
Having a
<img src="cat.gif" alt="Meow">
always helps
</div>
I have no problems finding the div element, when I invoke getText() I would wish to receive "Having a Meow always helps", but instead I get the text without the alt (Meow) description.
I agree this is the expected behaviour, but this is not what I need.
How can I preferably inline the alt text or at least get the text chunks in sequence with the inline image to verify the proper placement of the image inside the text?
selenium-webdriver works that way in both scenarios,
considers "alt" as attribute of image tag and not as element text for Div.
Considers "Having a always helps" as innerText of Div element.
i would suggest....to extract the Div text and img (alt) text separately. if text follows a pattern, try to identify sequence after or before which image attribute will be displayed.
WebElement Div_elem=Driver.findElement(By.id("soandso"));
String Div_text = Div_elem.getText();
String img_text=Div_elem.findElement(By.tagName("img")).getAttribute("alt");
would be glad if it helps
I found a solution here: How to get text of an element in Selenium WebDriver (via the Python api) without including child element text?
His suggested solution:
def get_text_excluding_children(driver, element):
return driver.execute_script("""
return jQuery(arguments[0]).contents().filter(function() {
return this.nodeType == Node.TEXT_NODE;
}).text();
""", element)
The element passed to the function can be something obtained from the find_element...() methods (i.e. it can be a WebElement object).
basically suggests that you use jQuery to get the text within the div.
gtk.Label(....) gives a label as a clickable link if the label-text is formatted as a link (text within a "a href-tag"). It is then automatically shown in blue and underlined. (How) can I change the style, e.g. remove the underlining and change the color?
Python 2.7.4, Windows7, gtk 2.24.10.
You can use a span tag to set text attribute.
Suppose label's text is:
GNU
now change it to:
<span foreground="blue" underline="none">GNU</span>
Here is the screenshot:
How do you display data in a 'textarea' using struts application,
This is my code:
<html:textarea property="comments" </html:textarea>
<bean:write name="FormBean" property="comments"/>
where FormBean is my beanclass and comment is a property in beanclass.
But I cannot get it too work.
Thanks in advance for your help.
If you use Struts action forms and you have the html:textarea tag inside your html:form tag (this tag is only valid when nested inside a form tag body) then the following code is all you need:
<html:textarea property="comments" />
Don't know what you are trying to do with bean:write but if you want to display that inside your html:textarea I'm not sure you can. The property attribute is mandatory for the html:textarea tag and will use that as the content.