### Archive

Posts Tagged ‘html’

## Load Testing web application with Selenium and TestNG

I’ve used Selenium for while to do verification tests of web applications, recently I discovered a very simple way to use it with TestNG and Maven to do some performance testing. TestNG allows for the use of annotations to allow multi-threading and iterations.

pom.xml:
 <dependencies> <dependency> <groupId>org.testng</groupId> <artifactId>testng</artifactId> <version>6.8.7</version> <scope>test</scope> </dependency> <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-java</artifactId> <version>2.44.0</version> <scope>test</scope> </dependency> <dependencies> 

And as for a simple test to get started with… scripting of steps is available online or could be in a future blog post.
 /* * COPYRIGHT. none */ package com.example.selenium;

 import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebDriverException; import org.openqa.selenium.firefox.FirefoxDriver; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.testng.Assert; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; /** * Simple test example for Selenium */ public class SeleniumTest { private static final Logger LOGGER = LoggerFactory.getLogger(SeleniumTest.class); /** * TODO Un-comment or change if needed to set your local path! */ @BeforeClass public void oneTimeSetUp() { System.out.println("-------------------------------------- init ----------------------------------------"); //System.setProperty("webdriver.firefox.bin","C:\\path\\to\\firefox.exe"); } /** * NOTE: uses TestNG - behaves differently than JUnit */ @Test(invocationCount = 1, threadPoolSize = 5) public void testLoadApp() { final String fn = "testLoadApp"; final String baseUrl = "http://www.giantgeek.com/index.php"; LOGGER.debug("[START] Thread Id: {} is started!", Thread.currentThread().getId()); WebDriver driver = null; final long start = System.currentTimeMillis(); try{ driver = (WebDriver)new FirefoxDriver(); driver.get(baseUrl); final String actual = driver.getTitle(); LOGGER.debug("Page Title is {}", actual); final String expected = "GIANTGEEK.COM"; Assert.assertEquals(actual,expected); //perform whatever actions, like login, submit form or navigation 

 }catch(final WebDriverException ex){ LOGGER.warn(fn+":WebDriverException:{}",ex); }catch(final Exception ex){ LOGGER.warn(fn+":Exception:{}",ex); } finally { final long elapsed = System.currentTimeMillis() - start; LOGGER.debug("[END] Thread Id: {}, elapsed={}", Thread.currentThread().getId(),elapsed); if(driver != null){ driver.quit(); } } } } 

WARNING: Selenium Tests MAY fail if the browser used for testing is updated in the Operating System. Updating the pom.xml to a newer release usually helps!

REFERENCES:

Categories: Tags:

## “msapplication-config” and browserconfig.xml

Windows-8/MSIE-11 introduced Tiles, as such server administrators may have started seeing HTTP 404 errors in their server logs as it attempts to look for a “browserconfig.xml” file at the root of a website domain. If you are inclined to use this file, you should definitely look into the documentation for how to best make use of it. Others may just wish to prevent the error from making “noise” in their log files.

To remove the error, add the following to your pages; alternately you COULD define the URL of your file as the ‘content’ attribute:
 <meta name="msapplication-config" content="none" /> 

You can alternately place an empty /browserconfig.xml on your web server for each domain.

An common example of how to use this file is below:
 <?xml version="1.0" encoding="utf-8"?> <browserconfig> <msapplication> <tile> <square70x70logo src="/mstile-70x70.png"/> <square150x150logo src="/mstile-150x150.png"/> <wide310x150logo src="/mstile-310x150.png"/> <square310x310logo src="/mstile-310x310.png"/> <TileColor>#8bc53f</TileColor> <TileImage src="/mstile-150x150.png" /> </tile> </msapplication> </browserconfig> 

REFERENCES:

Categories: Tags:

## Eclipse FileSync plugin

I’ve done a lot of front-end java coding over my career,  one particularly annoying aspect is the wait for a build (compile-deploy) cycle in my local developement servers to view or test a small change.  One particularly useful tool that I’ve been using for some time is a FileSync plugin for Eclipse.  It is useful as you can “map” folders from your Eclipse project to a path on your local filesystem, as such the individual files are automatically copied to your server installation.  I’ve personally used this approache with JBoss, Tomcat and WebSphere, but there is no reason that it should not work for other servers.

Categories: Tags:

## Preventing Pinterest “pinning” of your content

While many people are happy when images from their websites get “pinned” on Pinterest, there are many times that you might not be so pleased. You may have a need to prevent images from being shared for copyright or similar reasons, or simply not want the extra website traffic.

Thankfully, you can stop this with the addition of a simple HTML META tag. Also, if you already use CloudFlare, they can add it for you at runtime!

 <meta name="pinterest" content="nopin" /> 

REFERENCES:

Categories: Tags:

## Preventing Blackberry browser from messing up your UI

I’ve previously given steps to prevent phone numbers (and other elements) from being automatically reformatted by Skype Toolbar and IOS Safari, there is still a small segment of the user population that uses Blackberry devices that can similarly benefit from a little code.

The following stops auto detection and formatting of phone and email addresses on devices with the BlackBerry Browser.

HTML:
 <meta http-equiv="x-rim-auto-match" content="none" /> 

WML:
 <meta name="x-rim-auto-match" http-equiv="x-rim-auto-match" forua="true" content="none" /> 

REFERENCES:

Categories: Tags:

## Skype toolbar meta tag… preventing Skype from messing up your UI

I’ve previously documented the method used to prevent IOS devices from formatting numbers.

Users on other platforms, notably Windows, have Skype installed and it too can cause some headaches with your UI as it inserts elements to decorate phone numbers.

For users that have the Skype Toolbar enabled, the following META tag will prevent it from doing a lot of damage!

<meta name="SKYPE_TOOLBAR" content="SKYPE_TOOLBAR_PARSER_COMPATIBLE" />

REFERENCES:

Categories: Tags:

## HTML cleartype meta tag?

This tag allows for activation of ClearType in Mobile IE for smoothing fonts.

 <!--[if IEMobile]><meta http-equiv="cleartype" content="on" /><![endif]--> 

NOTE: Future use of this approach is questionable, as MSIE10 dropped support of conditional comments, and HTML5 validators (in general) do not “like” the http-equiv values as they are not standardized

REFERENCES:

Categories: Tags:

## Preventing IOS/Safari from formatting numbers

There are many cases where your application may display numbers that “resemble” phone numbers, but are not, unfortunately Safari’s default behavior is for it to be “helpful” and format them into clickable/callable links for the user of Apple IOS devices.

Adding the following META tag can prevent that default behavior:
 <meta name="format-detection" content="telephone=no" /> .

NOTE: I’ve seen some mention of using this method for ‘address=no’ and ‘email=no’, but have not looked into or verified those implementation yet!

REFERENCES:

Categories: Tags:

## Revisit-After meta tag

Once in a while I’ve seen this tag in the HTML source of older websites, I too had implemented it at one time, but forgot the reason. Here’s what I’ve turned up, and as such have removed it universally.

This tag was at one time used by one small search engine in Vancouver Canada, it was never picked up by the larger search organizations and as such has very little relevance.

<meta name=”revisit-after” content=”7 days” />

REFERENCES:

Categories: Tags:

## opensearchdescription.xml

OpenSearch is a relatively obscure topic that I’ve only crossed a few times, here is the premise.

A simple tag can be added to your content, in this case HTML, but a feed can also contain this element.
 <link rel="search" href="http://www.giantgeek.com/opensearchdescription.xml" type="application/opensearchdescription+xml" title="giantgeek.com" /> 

That link refers to a file that resembles the one below, in it you can specify the URL to the search facilities on a website, or as in the case below, use the parameters for a Google search of your website.
 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE OpenSearchDescription> <OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/"> <ShortName>GiantGeek.com</ShortName> <Description>Use Google to search our web site.</Description> <InputEncoding>UTF-8</InputEncoding> <Tags>giantgeek skotfred</Tags> <Contact>[email protected] /* <![CDATA[ */!function(){try{var t="currentScript"in document?document.currentScript:function(){for(var t=document.getElementsByTagName("script"),e=t.length;e--;)if(t[e].getAttribute("cf-hash"))return t[e]}();if(t&&t.previousSibling){var e,r,n,i,c=t.previousSibling,a=c.getAttribute("data-cfemail");if(a){for(e="",r=parseInt(a.substr(0,2),16),n=2;a.length-n;n+=2)i=parseInt(a.substr(n,2),16)^r,e+=String.fromCharCode(i);e=document.createTextNode(e),c.parentNode.replaceChild(e,c)}}}catch(u){}}();/* ]]> */</Contact> <Image width="16" height="16" type="image/x-icon">http://www.giantgeek.com/favicon.ico</Image> <!-- NOTE: this uses Google, you can give your own search url instead --> <Url type="text/html" method="GET" template="http://www.google.com/search?q=site:giantgeek.com {searchTerms}"/> <Url type="application/opensearchdescription+xml" rel="self" template="http://www.giantgeek.com/opensearchdescription.xml"/> </OpenSearchDescription> 

Many modern browsers that provide a ‘search box’ in the browser interface, can then add the capability to perform a search of your website even when the user is not there already.