0% found this document useful (0 votes)
16 views2 pages

fp2

Uploaded by

AnushaMainrai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views2 pages

fp2

Uploaded by

AnushaMainrai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

<project xmlns="http://maven.apache.org/POM/4.0.

0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.java</groupId>
<artifactId>SeleniumWithJava</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.53.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-htmlunit-driver</artifactId>
<version>2.52.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<!-- Maven Compiler Plugin for Java 1.8 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>

package com.java;

import org.openqa.selenium.*;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.interactions.Actions;

public class Main {

public static void main(String[] args) {


/*WRITE YOUR CODE*/
System.setProperty("webdriver.chrome.driver", "./chromedriver");

// Configure ChromeOptions for headless mode


ChromeOptions options = new ChromeOptions();
options.addArguments("--headless"); // Run Chrome in headless mode
options.addArguments("--no-sandbox");
options.addArguments("--disable-dev-shm-usage");
// Initialize WebDriver with ChromeDriver
WebDriver driver = new ChromeDriver(options);
driver.get("http://localhost:8000");
// Switch to the iFrame (assuming it's the first one on the page)
driver.switchTo().frame(0);
// Locate the draggable and the drop target elements
WebElement dragElement = driver.findElement(By.id("draggable")); //
Replace with actual element ID or selector
WebElement dropElement = driver.findElement(By.id("droppable")); //
Replace with actual element ID or selector
Actions actions = new Actions(driver);
actions.dragAndDrop(dragElement, dropElement).perform();

// Switch back to the main page content


driver.switchTo().defaultContent();
// Print the page source to the console
String pageSource = driver.getPageSource();
System.out.println(pageSource);
driver.quit();

You might also like