Friday, 1 January 2016

Python installation & Executing simple Program


How to download python:


Step 2: After download you will get executable file

             

Step 3: double click on executable file. After clicking you will get popup


               
Step 5: click on Run you will get another popup









Step: 7    Verify python installed or not: Go to system menu & type PYTHON





Step 8: Open command Prompt & type python






Step 8: After type python- sometimes u will get “Internal or external files” error

To solve – go to path before you have remember the path to installed





Step 10: Set Environment variables of python (copied path mention in Path variable & click ok)



Step 11: Close the command prompt & open new fresh command prompt & type python





Where we can write Python program
1Notepad
2Notepad++
3. Eclipse
4. Python shell prompt
Step 1: To write program in NOTEPAD & executing in command prompt
     1.1: Open notepad -write python sample print program




Step 1.2: save as to (demo.py)




1.3: Go to folder saves file will be display in python symbol





Step 3: Executing notepad file in command prompt
3.1:  copy the save file path – open command prompt




3.2: mention copied path & file name as (d.py) and enter




Step 2: Writing program & execution in python shell command
2.1: Type python in system menu – select IDLE




2.2: Shell command will open and type your program and execute





PYTHON in eclipse



How to install PYTHON in eclipse

Step 1: Go to help -> Install New Software


                    


Step 2: click on Add



Step 3: Type give name & loc((Name=PyDev and PyDev Extensions & loc: http://pydev.org/updates) & click ok
                 


Step 4: click on marked one & click finish


                


Step 5: click select marked one & click finish

            


Step 6: click on radio button & click finish


           
NOTE: It will take time to install & restart your system:
Step 7: check python is installed or not-à go to eclipse à window & click preferences
               



Step 8: click on interpreters





Step 9: click on NEW



STEP 10:  Type Python Name & Python installed Location in your system& click ok




Step 11: click on Apply & click ok



Step 11: Go to window à Open perspective & click PYdev -> click ok



Step 12: create new python project à click on File (eclipse)



Step 13: Enter Project Name & click marked radio button & click Finish



Step 14: Right click on SRC -> NEW -> PyDev Package




Step 15: Right click on package -> NEW  ->PyDev Module





Step 16: ENTER module Name ->click on Finish




Step 17: After click on Finish & popup appear click empty & ok




       How to register python to selenium
Step 1: open command prompt
Step 2: GO to python folder where it is installed in system [up to scripts you have to copy path)
Step 3: Mine is [C:\Users\DeskUser\AppData\Local\Programs\Python\Python35\Scripts]
Step 4: Navigate location to python folder in command prompt
Type below command
[easy_install selenium] --> enter


Step 18: Write simple program




Step 19 : Place cursor on end of webdriver [ press= ctrl +space]




Step 18: Import will be display &run program




Sunday, 27 December 2015

Click all linkspresent in a webpage

Click  all linkspresent in a webpage


private static String[] links = null;

private static int linksCount = 0;



@Test  

public void demo()

{
WebDriver driver = new FirefoxDriver();
driver.get("https://www.google.com");
List<WebElement> linksize = driver.findElements(By.tagName("a"));
linksCount = linksize.size();
System.out.println("Total no of links Available: "+linksCount);
links= new String[linksCount];
System.out.println("List of links Available: ");
// print all the links from webpage
for(int i=0;i<linksCount;i++)
{
links[i] = linksize.get(i).getAttribute("href");
System.out.println(linksize.get(i).getAttribute("href"));
}
// navigate to each Link on the webpage
for(int i=0;i<linksCount;i++)
{
driver.navigate().to(links[i]);
Thread.sleep(5000);


driver.navigate().to("https://www.google.co.in");
}