Showing posts with label "How to set the path of java". Show all posts
Showing posts with label "How to set the path of java". Show all posts

Get all links of a Webpage using Selenium


How to test links of any website?

public static void main(String[] args) {
WebDriver driver = new FirefoxDriver();
driver.get("https://www.google.co.in/");
List links = driver.findElements(By.tagName("a"));
System.out.println(links.size());    // to check the number of links present at webpage
for (int i = 1; i {
System.out.println(links.get(i).getText());
}
}

How to handle iFrames in Selenium?


A basic example of handling frames at www.espncricinfo.com

import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class Abc
{
public static void main(String args[])
{
WebDriver driver=new FirefoxDriver();
driver.get("http://www.cricinfo.com/");
driver.manage().timeouts().implicitlyWait(3000, TimeUnit.MILLISECONDS);
driver.findElement(By.linkText("Countries")).click();
driver.switchTo().frame(driver.findElement(By.xpath("//*[@id='ciHomeContentrhs']/iframe")));
driver.findElement(By.linkText("Cricinfo")).click();
}
}

How to setup Classpath for Java in Windows 7?



We all know the importance of CLASSPATH for Java. Setting PATH/CLASSPATH is very easy if we have the correct steps. I've listed down the steps which will help you to set CLASSPATH/PATH for Java:
 
Step 1: Download Java or JDK from the following URL according to your computer configuration:
Step 2: Install it by click on setup.exe and following the steps.
Step 3: By default JDK installs at "C:\Program Files\Java\jdkxxx.xx" location only. Unless we change the location at the time of installation.
Step 4: Go to JDK installed location, open bin folder available at the location. Now, copy the path.
Step 5: Right-click on My Computer icon available at your desktop and select Properties.
Step 6: Now, click on Advanced System Settings and click on Advanced tab from the dialog box opened
Step 7: Click on Environment Variables and then System Variables.

Step 8: Edit path and add the copied bin (which we did in Step 4) in that. Below are some images to help you:



Step 9: Click on OK of Environment Variables window and System Properties window.
Step 10: To verify whether Classpath or path of java is set up correctly or not.

Open Command Prompt and enter java -version. You'll find a statement like mentioned below:

java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)