Hi guys I need for my project a CSS parser. I just look around and I find always the same libraries. But they don't have the implementation for obtaining the CSS file or code from a website. All of them need local files that I don't have because I want to analyze for example Facebook or Twitter etc.
Is there a library for this purpose?
I already found libraries like -> CSSPARSER, SAC
EDIT:
Found a solution for my problem. First of all, I use JSOUP to find out which link belongs to the CSS stylesheet. Then I filter it and save the URL to the CSS file into a string variable. After that, I download this file by the given name and put this file into the CSS parser and now its works.
Related
I need to click on a pdf file in the browser and the verify the contents in that,
By using below code am able to click on the pdf link but i can't verify the contents inside that pdf link ,the pdf is embedded in object.
How can we locate an element inside object tag and perform some actions on pdf file(html type).
To click on pdf link..
WebElement element = driver.findElement(By.xpath("//div[#id='iconDock']/div/a[7]/img"));
element.click();
This code to verify content in pdf(its not working).
WebElement objectTag = driver.findElement(By.xpath("//div[string(#id)='reportPanel']//object/html/body//div[#id=\"outerContainer\"]/div[#id=\"viewer\"]/div[#class=\"textLayer\"])"));
Help me out please
you cannot verfiy the contents of the pdf using webdriver, u need to integrate with a tool called PDFBOX.Please find the link to give u basic understanding how to use it.
http://seleniumeasy.com/selenium-tutorials/how-to-extract-pdf-text-and-verify-using-selenium-webdriver-java
Selenium cannot interact with a PDF, it is a library for driving a web browser.
The best advice is don't use WebDriver for downloading files. Use it to get file locations and then use a different library to actually download files.
The easiest way to check a file is take an MD5/SHA1 hash of a known good copy of a file and then compare it with the MD5/SHA1 hash of the file you have downloaded. It's how everybody checks that the file they have downloaded is correct.
More info in this blog post:
http://ardesco.lazerycode.com/index.php/2012/07/how-to-download-files-with-selenium-and-why-you-shouldnt/
I want to make the js and css files which are modified are to be downloaded at the client end when a page is accessed. I have these approaches
Manually add the modified timestamp the URL in each page.
I was thinking of writing a scriptlet code in all the jsp pages which will read all the js and css files modified timestamp and append it to the url in the page.
Add the modified timestamp while building the war file using ANT.
I have following questions.
Can any one let me know which would be a better solution of the above approaches? I am open to any other solutions also.
I went through this answer on SO and using it I can get the modified date but how to change the jsp file?
Is there anything similar to this in java?
In this situation better or best solution is took shape according to your exact requirements. I might derive simple questions like; Will your static resources in same server or included in your app in same server etc.. May be some other better ways..
I don't have ant experience so I can't talk about it now , but you can go with java way already.I want to share just idea/s. A filter(looks the .css or .js requests , gets resources and look resource lastmodified date or checksum return as version on response) or custom jsp tag will provide your requirements. Write a custom jsp tag <resource:static path="app.js"/> like that example. So it may look specific file's last modified date, assumed under the same document root, and it can produce <script type="text/javascript" src="app.js?version=8637"> like this result, so this result will bust the cache.
I am a total newbie in webdesign and I have created a site using the Joomla CMS. However, on a particular page within the site I am trying to launch an interactive calculator that uses java via .class files which are called by an .html file. I used the embedding tag:
<embed src="images/Calculator/classes/examples/PayeCalc.html"
type="application/x-java-applet"
width="1108" height="407">
Nothing shows up on the page however, when I preview it. What am I doing wrong? The .class files are saved in the folder that the .html file is located. Isn't it supposed to call up the files as needed? Why is the page just blank? Can anyone help this newbie to resolve this issue?
Thanks in advance.
Check if your text editor removes the embed tag.
It can happen from the joomla text filters or from the text editor.
Try using JCE text editor and follow the steps described here
Also if you use RSFirewall check this out
Good luck
I'm using #ResourceDependency annotation in a JSF component to add Javascript and CSS files into my JSF page.
In my Javascript file, I need to reference another resource file (a .swf file, which located in META-INF/resources, as JSF requires). I tried to put a #{resource['swf:file.swf']} EL expression in my javascript code, but it won't get resolved.
For exapmle, for the following JS file in the server:
var instance = new JSClass();
instance.setResourceUrl("#{resource['swf:file.swf']}");
The browser gets:
var instance = new JSClass();
instance.setResourceUrl("#{resource['swf:file.swf']}");
which is wrong.
While when I put the same EL in the CSS file, it get resolved properly. For the following CSS file in the server:
.instance-css-class {
background: url("#{resource['swf:file.swf']}")
}
The browser gets:
.instance-css-class {
background: url("/webapp/javax.faces.resource/file.swf.jsf?ln=swf")
}
Which is exactly what I need, but in the JS file.
Obviously, I can use the CSS as a workaround for the issue (Create a DOM element, attach the CSS class to it, and then read and parse the required style property). But, is there a more elegant way to achive it? Is it a bug in the JSF library (I'm using Mojarra 2.0.3, with Jboss 6.1), or there is a reason for that behavior?
Please mind that the code above is part of a tag library, so workarounds such as those can't be used.
Edit - Seems that the CSS workaround is not feasible, since I can't see a way to get CSS attribute from a CSS file. So any (working) workaround would be gladly accepted as well.
BalusC has answered a similar question in detail here. Though the first solution is the easiest to implement, I would recommend you to go with the third, which in my opinion, is the correct way.
im about to write a class that takes a look on the html source code and filters all pdf links from it. the idea behind it is just take the parent link + the relative link..
basically it's working for
pdf
but in some cases it doesn't e.g. if the same pdf link is written as
pdf
or
pdf
(point and space) both are working links and goes to the same pdf in the same directory if they are parsed in browsers, but for the composition in my class completely useless.
i fixed the problem for the two cases above. the question is if there are other special cases in syntax where i should pay attention on.
You do not know what the link points to until you download the file.
I can have a link like http://www.mysite.com/pages/brochure.html which internally redirects to a PDF file.
So, if you're not in control of the links, or working on a particular section of your site, you're going to fail.
On the other hand, if you're working on a specific section of the site, where you know every PDF link has a .pdf estension, you can simply check the extension and not the whole path (don't know how's written in Java the .lastIndexOf("string") thing of C#).