Selenium WebDriver-এ টেক্সট ইনপুট বক্সে এন্টার (Enter) কী প্রেস করার অনুকরণ করতে `sendKeys` মেথডে `Keys.ENTER` বা `Keys.RETURN` পাস করতে হয়। `org.openqa.selenium.Keys` প্যাকেজ ইম্পোর্ট করতে হয়।

উদাহরণ ১: Keys.ENTER ব্যবহার
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
public class PressEnter {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "C:\\Users\\ghs6kor\\Desktop\\Java\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("https://www.tutorialspoint.com/about/about_careers.htm");
// এলিমেন্ট চিহ্নিত করা
WebElement l = driver.findElement(By.id("gsc-i-id1"));
l.sendKeys("Selenium");
// এন্টার কী প্রেস
l.sendKeys(Keys.ENTER);
driver.close();
}
}
উদাহরণ ২: Keys.RETURN ব্যবহার
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
public class PressReturn {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "C:\\Users\\ghs6kor\\Desktop\\Java\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("https://www.tutorialspoint.com/about/about_careers.htm");
WebElement l = driver.findElement(By.id("gsc-i-id1"));
l.sendKeys("Selenium");
// রিটার্ন কী প্রেস
l.sendKeys(Keys.RETURN);
driver.close();
}
}
নোট: `Keys.ENTER` এবং `Keys.RETURN` প্রায় একই কাজ করে, তবে কিছু ব্রাউজার/ওএসে আচরণ ভিন্ন হতে পারে। উভয়ো ট্রাই করা ভালো।