Assignment 9
Assignment 9
1. Download JDK:
o Go to the Oracle JDK download page (or the version you need).
o Download the appropriate installer for your operating system.
2. Install JDK:
o Run the installer and follow the instructions.
o Set the JAVA_HOME environment variable:
▪ Windows:
▪ Right-click on This PC -> Properties -> Advanced system
settings -> Environment Variables.
▪ Add a new variable named JAVA_HOME and set the value to the
path of your JDK installation (e.g., C:\Program
Files\Java\jdk-11).
▪ Mac/Linux:
▪ Open a terminal and add the following line to your
~/.bash_profile or ~/.bashrc:
bash
Copy code
export
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-
11.jdk/Contents/Home
3. Verify Installation:
o Open a command prompt or terminal.
o Type java -version to confirm the installation.
1. Download Eclipse:
o Go to the Eclipse download page.
o Download the installer for your operating system.
2. Install Eclipse:
o Run the installer and follow the instructions.
o Choose the Eclipse IDE for Java Developers package.
java
Copy code
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
// Navigate to a webpage
driver.get("https://www.example.com");
bash
Copy code
java -jar selenium-server-standalone-x.xx.x.jar -role hub
o Replace x.xx.x with the actual version number of the jar file.
o This will start the Selenium Grid Hub on http://localhost:4444.
bash
Copy code
java -jar selenium-server-standalone-x.xx.x.jar -role node -hub
http://localhost:4444/grid/register
1. Open a Browser:
o Go to http://localhost:4444/grid/console.
o You should see the hub and the registered node listed there.
java
Copy code
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import java.net.MalformedURLException;
import java.net.URL;
// Navigate to a webpage
driver.get("https://www.example.com");