Sunday, June 30, 2013

Facebook : How to Avoid unwanted tags in Pictures or posts

Facebook : How to Avoid unwanted tags in Pictures or posts

On FB we all are facing problem related to unwanted tags in friends posts.

Your friends without asking you tags in your posts just to get more likes

So how to avoid it, facebook already has a very nice way of avoiding this but it seems very few people are aware of it

Solution
1. Go to account settings
2. Click Timeline and Tagging
3. In who can add things to my time line, Enable "Review posts friends tag you in before they appear on your timeline?"

Now each time some one tags you, facebook first ask you to review it and then adds it your time line

You can also remove multiple tags using this feature

selenium Mosue Over not working if hover property is defined in CSS

Problem

Selenium is not able to perform mouseOver if Hover property is defined in CSS
You can try yourself on this link using selenium ide http://www.w3schools.com/cssref/tryit.asp?filename=trycss_sel_link_more2
Selenium mouse Over has no effect on this link
please visit this link

Solution

According to this question, this is one of those perennial problems Selenium and :hover css
They discuss a couple of solutions, but it looks like the problem is that as Javascript cannot trigger the :hover pseudo class, so Selenium can't either.

You can use webdriver to solve this problem, Webdriver code for mouse over

void mouseOver(String UiLocator) throws Exception
{
element =  driver.findElement(findBy(UiLocator));
Actions builder=new Actions(driver);
builder.moveToElement(element).build().perform();
}


Selenium: Is there any JS (JavaScript) code coverage tool which we can integrate with Selenium Server/RC

Solutions
1.
I don't know what you are trying to achieve, but:
  • Selenium is testing the final output, as seen on the page itself.
So it really does not matter if its PHP, HTML, JSP, ASP or .NET - the Selenium is designed to mimick the end user and click the final application - the final HTML code generated by whatever is under the hood.
Selenium is also not that good for code coverage tests - one piece code can be on many pages - so better approach with selenium is to do the "user" coverage - try to cover all the possible actions which living human could possibly do with your page

2.
Not aware of a tool for Selenium, but JsTestDriver has a design very similar to Selenium RC (can launch tests from the command line and they are run on a server that drives browsers headlessly) and provides code coverage information.
IntelliJ integrates with JsTestDriver and provides a visual display of coverage information.

3.
In theory, you can use any coverage tool that instruments JavaScript code to collect coverage data.
For example, you can use JSCoverage either in proxy mode (for real-time instrumentation) or for static instrumentation to run your Selenium tests off the instrumented code.
One technical hurdle could be to devise a way to accumulate coverage data across multiple pages. The coverage tool of your choice could already have support for accumulation of data from multiple page runs. If not, you might have to handle that bit yourself, but this is probably not something trivial.

4.
There is no particular tool that can integrate with Selenium to do JS coverage. However there are lots of tools which test JS on every page which can tell if the JS that executing on your web page had any errors. This may not ideal solution but on each page you will have the measure of uptil which point JS executed properly on your webpage under test. There are two solutions for that:
1.) JSErrorCollector API: It will integrate directly with Selenium and let you know if there were any error on the page. Can be found at: http://mguillem.wordpress.com/2011/10/11/webdriver-capture-js-errors-while-running-tests/
2.) Full fledged JS coverage tools: There is an excellent list of tools here which will essentially help you in covering JS on on your web pages. Can be found at: Looking for a better JavaScript unit test tool

5.
I've integrated this tool in my Selenium tests a time ago. You need a bit of work to gather coverage info before page changes (in any case js trigger a page reload, link etc...)
Once you set up everything, it will fully coverage any js executed while Selenium load and test your website pages.
PS : Even if it was specially adapted for YUI test, you can use it with selenium.

Ant: copying a directory from one windows system to another

Problem
How to copy a directory from a windows system to a remote windows system using ant
there is one scp command and FTP command, please provide me an example to perform this task using scp and ftp.
Also scp requires SSH which is not common for windows system.
So how to use SCP on windows system using ant
Also if you know any better approach for windows system using ant or java, please share
Also there is one SC command(don't know how to use it)

Solutions
1.
Download:
<scp file="${username}:${password}@${ip}:${path-to-file}" todir="${dir}" trust="true" />
or Upload:
<scp file="${path-to-file}" todir="${username}:${password}@${ip}:${dir}" trust="true" />  
Ant scp task provides attributes such as localFile and remoteFile to replace "file", and localTofile / localTodir and remoteTofile / remoteTodir to replace "dir". Using these attributes can help avoid confusion when you need some scp tasks to get files from the server to local machine, while others to upload files from the local machine to server.
Like this (for uploading):
<scp localFile="${path-to-file}" remoteTodir="${username}:${password}@${ip}:${dir}" trust="true" />
Check the ant manual to see more information: http://ant.apache.org/manual/Tasks/scp.html
Note:
1. Avoid copying multiple files; Copy a zip archive and a ant build file together with it, and unzip on target machine.
2. Using scp, you need to setup ssh server on the target machine; you also need to put jsch.jar in your ANT_HOME/lib. The jsch.jar can be downloaded from

2.
You should go for using FTP to copy files between the windows machines. There are other protocal too, but you should go with FTP.
A sample for using FTP.
<ftp server="${server.location}"
   remotedir="${directory.to.copy}"
   userid="${ftp.username}"
   password="${ftp.password}"
   depends="yes">
   <fileset dir="**Files****"/>
</ftp>
You can further look for details here. There are many options to try there.

3.
To copy a directory from your local host to a remote host using the ant scp, you have to specify the parent of the directory to the fileset and include the directory name eg.
<scp todir="user@hostname:/destination/dir/" keyfile="id_dsa" passphrase="abc" sftp="true" >
    <fileset dir="${parentDir}/"  >
        <include name="**/${dirToCopy}/" />
    </fileset>
</scp> 
sftp="true" helped another user on this subject so I included it. In my case I believe that adding the "/" at the end of the parentDir and dirToCopy, which signifies a directory at the command line, finally let me copy a directory and not just it's contents.

xpath and selenium : locate a node using exact text match

Problem

I want to locate a Element on a Web Page using text
I know there is a method name contains to do so
ex
tr[contains(.,'hello')]/td
But problem is if i have two elements name hello and hello1 then this function does not work properly
is there any other method like contains for exact string match for locating elements

Solutions
1
Well, your problem is that you are searching text into the tr (which is not correct anyway) and this cause a problem to the function contains which cannot accept a list of text. Try to use this location path instead. It should retrieve what you want.
//tr/td[contains(./text(),"hello")]
This location path will retrieve a set of node on which you have to iterate to get the text. You can try to append the
/text()
but this will cause (at least on my test) a result that is a string which is a concatenation of all the matched strings.

2.
tr[.//text()='hello']/td
this will select all td child elements of all tr elements having a child with exactly 'hello' in it. Such an XPath still sounds odd to me.
I believe that this makes more sense:
tr/td[./text()='hello']
because it selects only the td that contains the text.
3.
It all depends on what your HTML actually contains, but your tr[contains(.,'hello')]/td XPath selector means "the first cell of the first row that contains the string 'hello' anywhere within it" (or, more accurately, "the first TD element in the TR element that contains the string 'hello' anywhere within it", since Selenium has no idea what the elements involved really do). That's why it's getting the wrong result when there are rows containing "hello" and "hello1" - both contain "hello".
The selector tr[. ='hello']/td would be more accurate, but it's a little unusual (because HTML TR elements aren't supposed to contain text - the text is supposed to be in TH or TD elements within the TR), and it probably won't work (because text in any other cells would break the comparison). You probably want tr[td[.='hello']]/td, which means "the first TD element contained in the TR element that contains a TD element that has the string 'hello' as it's complete text".