package playground; import com.google.common.util.concurrent.Uninterruptibles; import io.github.bonigarcia.wdm.WebDriverManager; import org.openqa.selenium.By; import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import java.time.Duration; public class OverlappedElement { private WebDriver driver; @BeforeClass public void StartSession() { WebDriverManager.chromedriver().setup(); driver = new ChromeDriver(); driver.manage().window().maximize(); driver.get("http://localhost:3000/overlapped"); } @AfterClass public void CloseSession() { Uninterruptibles.sleepUninterruptibly(Duration.ofSeconds(5)); driver.quit(); } @Test public void test01_Overlapped() { WebElement id_field = driver.findElement(By.id("id")); WebElement name_filed = driver.findElement(By.id("name")); WebElement subject_field = driver.findElement(By.id("subject")); JavascriptExecutor js=(JavascriptExecutor)driver; //js.executeScript("arguments[0].scrollIntoView(true);",id_field); id_field.sendKeys("fakeid2022"); js.executeScript("arguments[0].scrollIntoView(true);",name_filed); name_filed.sendKeys("kuku"); //js.executeScript("arguments[0].scrollIntoView(true);",subject_field); subject_field.sendKeys("This is test 01"); } }