selenium webcrawler

24
Selenium Webcrawler PRODUCED BY: RABIA KHALID

Upload: rabia-khalid

Post on 17-Feb-2017

768 views

Category:

Education


1 download

TRANSCRIPT

Page 1: Selenium webcrawler

Selenium WebcrawlerPRODUCED BY:RABIA KHALID

Page 2: Selenium webcrawler

Download and install java

First of all you need to install JDK(java development kit) Second you have to install JRE(java runtime environment)

http://www.oracle.com/technetwork/java/javase/downloads/index.html

Page 3: Selenium webcrawler

Download JDK and JRE

Page 4: Selenium webcrawler

Install Firefox

Now install mozila firefox https://www.mozilla.org/en-US/firefox/new/

Page 5: Selenium webcrawler

Install Firebug and FireXpath

Now install firebug and fire path into mozila firefox https://addons.mozilla.org/en-us/firefox/addon/firebug/ Now install FIreXpath https://addons.mozilla.org/fr/firefox/addon/firepath/

Page 6: Selenium webcrawler

Firebug

Now click on firebug On right-top of browserTo get firebug on. After installing it will be looked like this.

Page 7: Selenium webcrawler

Download Eclipse

Download Eclipse.. http://www.eclipse.org/downloads/packages/eclipse-ide-java-and-dsl-developers/marsr Download 64-bit or 32-bit according to your operating system..

Page 8: Selenium webcrawler

Install selenium web Driver

selenium web driver http://docs.seleniumhq.org/download/

Page 9: Selenium webcrawler

Start Eclipse

Extract all files after downloading and install them.. Now Start eclipse..

Page 10: Selenium webcrawler

Conti…

First time when you start eclipse it will ask for workspace where your work will be stored.

After selecting workspace folder , eclipse will be opened. Now create new project in eclipse and import all libraries of selenium.

Page 11: Selenium webcrawler

Create New Project

Create project File -> New -> java project

Page 12: Selenium webcrawler

Conti..

Give name to your project

Page 13: Selenium webcrawler

Create class

New right click on your project. create new class.

Page 14: Selenium webcrawler

Conti..

Now give name to your class. Select public static void option. finish

Page 15: Selenium webcrawler

Add libraries of selenium

Now right click on your project select properties.

Page 16: Selenium webcrawler

Conti…

Now select java build path.

Page 17: Selenium webcrawler

Conti..

Now select libraries Add external JARs..

Page 18: Selenium webcrawler

Conti…

Now import all selenium JARs..

Page 19: Selenium webcrawler

Conti..

It will be looked like this.

Page 20: Selenium webcrawler

Code

Now selenium libs are added to your project. Now write your code to test. …………….. Start……………. WebDriver driver = new FirefoxDriver(); driver.get("URL"); // write URL here of any website to open it in

browser driver.close();

Page 21: Selenium webcrawler

Test webdriver

Now write code and test byClick on run button.This code will run google on mozilafirefox.IT means test is passed.If any error occurs then check your libraries of selenium. all libs should be imported.

Page 22: Selenium webcrawler

Commands

Clicking on any element or button of webpage driver.findElement(By.id("submitButton")).click(); Store text of targeted element in variable String dropdown = driver.findElement(By.tagName("select")).getText(); Typing text in text box or text area. driver.findElement(By.name("fname")).sendKeys("My First Name");

Page 23: Selenium webcrawler

Applying Implicit wait in webdriver driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS); Get page title in selenium webdriver driver.getTitle(); Get Current Page URL In Selenium WebDriver driver.getCurrentUrl(); Navigate to URL or Back or Forward in Selenium Webdriver driver.navigate().to("http://www.google.com"); // you can add any website driver.navigate().back(); // navigate to back webpage driver.navigate().forward(); //navigate to forward webpage

Page 24: Selenium webcrawler

Here is my code which extract links from a website and show data by getting elements of website..

https://github.com/RabiaMughal001/crawler/blob/master/webcrawler.java

Thanks…. If you have any kind of problem then email me at

[email protected]