Sunday, 31 May 2015

== Search Text for Your Name ==
We'll want to place the if statement inside our for loop to make sure the program checks the if statement each time it moves forward through the loop. Essentially, the for loop is saying: "Hey program! Go through every letter in 'text'." The if statement will say: if you see something interesting, push that text into an array!"

var myArray =  ['a', 'b', 'c'];
myArray[0]; // equals a.

Instructions:
Add your if statement in the body of your for loop. It should check to see whether the current letter is equal to the first letter of your name. (Capitalization counts!)
There's no need to put anything between the {}s of your if just yet.

Solutions:

var text = "Hello world Keya how you doing Keya";
           
var myName ="Keya";
var hits = [];
for(var i=0; i<text.length; i++ )
{
    if (text[i]=== 'K')
    {
        }
    }
While loop: Tutorial 5/11
== Practice makes perfect ==
Problem: Write a while loop that logs "I'm looping!" to the console three times. You can do this however you like, but NOT with three console.log calls. Check the Hint if you need help!

Solve:
var count= 0;

var loop = function(){
    while(count < 3){
        console.log("I'm looping!");
        count++;
    }
};

loop();

Python Pig Latin 4/11


print "Welcome to the Pig Latin Translator!"

# Start coding here!
original = raw_input("Enter a word:")
if len(original) > 0:
    print original
else:
    print "empty"

Python-Conditionals-and-Control-Flow 15/15

If...elif...else

Code:
def the_flying_circus():
    if 12 and 1 + 1 == 2:    # Start coding here!
        print "Yes, I'm greater than 11!"
        # Don't forget to indent
        # the code inside this block!
        return True
    elif 11 < 12:
        print "We are a circus of less than 12 men!"
        # Keep going here.
        return True
    else:
        print "We don't know how many people we are!"
        # You'll want to add the else statement, too!

Thursday, 28 May 2015

Python datetime format

Problem domain:
  1. Create a variable called now and store the result of datetime.now() in it.
  2. Then, print the value of now.
Solve: 

from datetime import datetime

now = datetime.now()
print now

Output: 
current date

Printing current date year and month code

Format 1:
from datetime import datetime
now = datetime.now()
print now
print now.year
print now.month
print now.day


Format 2: from datetime import datetime
now = datetime.now()


print '%s/%s/%s' % (now.month, now.day, now.year, )


Format 3: from datetime import datetime
now = datetime.now()


print '%s:%s:%s' % (now.hour, now.minute, now.second )
Format 4: from datetime import datetime
now = datetime.now()


print '%s/%s/%s %s:%s:%s' % (now.month,now.day,now.year, now.hour, now.minute, now.second )

Saturday, 16 May 2015

Faced the following problem for send keys in selenium webDriver in Java

Java is throwing the following error while working with selenium
the method sendkeys(charsequence ) in the type webelement is not applicable for the arguments

It has a simple solution. Change your compiler compliance level from 1.4 to 1.7.
Follow these steps in your eclipse:
  1. Right click on your java project and select Build Path -> Click on
    Configure Build Path...
  2. In project properties window, Click/select Java Compiler at the left
    panel
  3. At the right panel, change the Compiler compliance level from 1.4 to 1.7
    (Select which is higher version in your eclipse)
  4. Lastly Click on Apply and OK
Now check your code. it will never show the same error.


Wednesday, 13 May 2015

TestNG file execution Along with jar file.

TestNG file execution Along with jar file.
1. Create a main class 1st

package Testcase;

import com.beust.testng.TestNG;

@SuppressWarnings("deprecation")
public class MainOne {

public static void main(String[] args) {
TestNG testng = new TestNG();
         Class[] classes = new Class[]{houpad.class}; //houpad is the class where i included all the                                                                                             //testNG executable testcases.
         testng.setTestClasses(classes);
         testng.run();

}

}

To export a jar file
1. Run the main class then
2. Right click on the package name> Export> Java> rurnnable JAR file> from the launch configuration select the main class created above.> Hit finish.
3. Now double click on the jar file
4. It will show the execution

http://testng.org/doc/documentation-main.html#running-testng-programmatically