I'm facing a situation where I want to display a link like this:
For more information check out our FAQ.
Where the full stop is displayed right after the link. It's seems like an Overkill to define multiple properties for this like
E.g.
faq.info=For more information check out our
faq.markup=FAQ
faq.href=http://www.some.very.nice.url.com
faq.fullstop=.
Neither do I want to include the dot only in the html. Is it possible to insert the dot at the end or the link inbetween?
You can embed components inside string messages:
<wicket:message key="faq.info">
<a wicket:id="faq">
<wicket:message key="faq.info.label"/>
</a>
</wicket:message>
faq.info=For more information check out our ${faq}.
faq.info.label=FAQ
For this to work you'll have to add a link with id "faq" from your Java code.
Related
I am trying to click on an image, but after each execution or when new swssion of the application opened the "id" assigned to that image changes as mentioned below. Please help me with this.
<img class="x-form-trigger x-form-arrow-trigger" id="ext-gen307" src="/slm/js-lib/ext/2.2/resources/images/default/s.gif" complete="complete"/>
<img class="x-form-trigger x-form-arrow-trigger" id="ext-gen306" src="/slm/js-lib/ext/2.2/resources/images/default/s.gif" complete="complete"/>
<img class="x-form-trigger x-form-arrow-trigger" id="ext-gen308" src="/slm/js-lib/ext/2.2/resources/images/default/s.gif" complete="complete"/>
I would personally prefer to use the id, name or title attribute to match. Since the image you want has an id, you can match on that.
The ID however, appears to be dynamic so you need to account for this.
driver.findElement(By.cssSelector("img[id^='ext-gen']"))
This, in english means "Find me an <img> that has an id="" attribute that *starts with* "ext-gen"
You can match on the src, but personally you should prefer other attributes that are less-likely to change, such as the ID.
See this page for a reference on CSS selectors for Selenium.
Try this, This would work perfect.
driver.findElement(By.cssSelector("img[src*='s.gif']"))
please update incase this is not working
I would rather go with src attribute to identify the image as this would change rarely. Even if it changes, then it makes sense that the test is failing.
driver.findElement(By.xpath("//img[#src='/slm/js-lib/ext/2.2/resources/images/default/s.gif']"))
Or
I would use a combination of a part of id along with src
driver.findElement(By.xpath("//img[#src='/slm/js-lib/ext/2.2/resources/images/default/s.gif'][contains(#id,'ext-gen')]"))
I'm using struts2 framework(java/js/html/css combo) for my webapp. I am reading a text file from server and I want to write the response to an iFrame present in the same jsp.
Flow:
(1) On click of a link, I pass the relative URL of the text file to jsp.
(2) When the jsp page loads, the java code in the jsp reads the file from server.
(3) Now this response has to be written to an iFrame present in the same jsp file
Can anyone plz help me in writing such response to an iFrame?
Thanks in advance :)
[code not tested, only a demostration of the concept]
here's some very rough idea as to how to fix your code, they definitly not the best but they should be enough to help you understand the concept.
However I'd still recommend going over the whole concept and maybe come up with a more efficent way to do what you need.
if you insist on using iframe, you need to make use of 2 seperate jsp as W3C says in "Implementing HTML Frames":
Any frame that attempts to assign as its SRC a URL used by any of its ancestors is treated as if it has no SRC URL at all (basically a blank frame).
so you'll need 2 jsp, the first one is basically what you have but the the src of the iframe changed to:
<iframe scrolling="yes" width="80%" height="200" src="second.jsp?content=<%=all%>" name="imgbox" id="imgbox">
and the second one will be something like :
<html><body><%= request.getAttribute("content") %></body></html>
From the code you've shown you forced a "content update" on the iframe by using javascript. The proper/usual way to update an iframe is to provide different input parameter to the second jsp and let it update it for you.
Finally, I'd recommend using JSTL as much as possible instead of scriptlets. It is much cleaner.
What you need to do is set the src attribute of the IFRAME to the jsp url when your link is clicked. Another way to do it is doing something like this:
<iframe src="" name="iframe_a"></iframe>
<p>W3Schools.com</p>
with the correct parameters of course
I'm currently writing a Webcomic Reader app, and so far I have been able to extract out the 'Next' and 'Previous' links from the comic websites, provided that when I parse them using JSoup, I can get a a[href] tag that is valid and contains the value for the 'Next' or 'Previous' Link.
An example will be http://www.explosm.net/comics/ , When I parse them using JSoup I can find the tag "< Previous", which contains the value of the previous link.
However, this only works on websites with valid tags, but on some websites, they do not display tags for their a[href] stuff, for example http://awkwardzombie.com/
So is there a method/technique where I can find the link I want, from these kind of websites without using tags?
For awkwardzombie.com, look at the hyperlink image's alt attribute, which gives an indication:
<img src="images/aznavb4o.png" alt="Next Comic" width="40" height="40" border="0">
I'm trying to extract some certain data from a website using JSoup and Java. So far I've been successful in what I'm trying to achieve.
<ul class="beverageFacts">
<li><span>Årgång</span><strong>**2009** </strong></li>
I want to extract what is inside the ** in the above HTML. I can do this by using the code that follows in JSoup:
doc.select("ul.beverageFacts li:lt(1) strong");
I'm using the lt(1) because there are several more list items following that I want to omit.
Now to my problem; there's an optional information tab on the site I'm extracting data from, and it also has a class called "beverageFacts". My code will at the moment extract that data too, which I don't want it to do.
The code is further down in the source of the website, and I've tried to use the indexer :lt(1) here aswell, but it wont work.
<div id="beverageMoreFacts" style="display: block">
<ul class="beverageFacts"><li class="half">
<span> Färg</span><strong> Ljusgul färg.</strong>
My overall result is that I extract "2009 Ljusgul färg." instead of only "2009". How can I write my code so it will only extract the first part, which it succesfully does, and omits the rest?
EDIT:
I get the same result using:
doc.select("ul.beverageFacts li:eq(0) strong");
Thanks,
Z
You are qualifying only one part, whereas you should qualify both. Try this:
doc.select("ul.beverageFacts:eq(0) li:eq(0) strong");
What you are saying is: give me the first list item of each list of beverages. What you need to say instead is: Give me the first item of the first list of beverages.
I all, I'm new to the ADF language and after a long search and failed tries, I have to ask how can I change a button layout - background, border, ... - using the CSS and the property "styleClass" of the ADF?
In my .jspx I have something like:
<af:commandButton action="#{backing_test.echoAction}" id="echo1" text="Save 1" styleClass="commandButton.buttonSaveTest" />
The thing is, after opening firebug, I found out that instead of a regular button, I have an image!
Thanks for you help!
You can't rely on what generated HTML you'll get for a specific component in ADF. The best way to get your own look and feel is to implement your own 'skin', which extends one of those already provided by ADF (eg, 'blafplus', or 'fusion', the new default). You then use the CSS selectors for the component you want, eg
af|inputText::content {
background-color: red;
}
Check out the following link to learn about skinning
http://download.oracle.com/docs/cd/E17904_01/web.1111/b31973/af_skin.htm#BAJFEFCJ
The hosted demo is an excellent way of finding out how to skin specific components. Eg, for your command button, check out:
http://jdevadf.oracle.com/adf-richclient-demo/faces/components/skinningKeys/commandButton.jspx