কম্পিউটার টিউটোরিয়াল

Selenium-এ এডিট বক্সের মান পাওয়ার উপায়


Selenium-এ এডিট বক্সের মান নিচের উপায়ে পাওয়া যায় -

  • getText() মেথড ব্যবহার করে।

  • JavascriptExecutor ক্লাস ব্যবহার করে।

getText() মেথড দিয়ে কোড বাস্তবায়ন।

উদাহরণ

import org.openqa.selenium.By; import org.openqa.selenium.Keys; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import java.util.concurrent.TimeUnit; public class GetValueScripting {    public static void main(String[] args) {       System.setProperty("webdriver.chrome.driver", "C:\\Users\\ghs6kor\\Desktop\\Java\\chromedriver.exe");       WebDriver driver = new ChromeDriver();       String url = "https://www.tutorialspoint.com/index.htm";       driver.get(url);       driver.manage().timeouts().implicitlyWait(12, TimeUnit.SECONDS);       String text = driver.findElement(By.className("gsc-input")).getText();       System.out.println("Extracted text is " + text);       driver.close();    } }

JavascriptExecutor ক্লাস দিয়ে কোড বাস্তবায়ন।

উদাহরণ

import org.openqa.selenium.By; import org.openqa.selenium.Keys; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import java.util.concurrent.TimeUnit; import org.openqa.selenium.JavascriptExecutor; public class ExtractValueScripting {    public static void main(String[] args) {       System.setProperty("webdriver.chrome.driver", "C:\\Users\\ghs6kor\\Desktop\\Java\\chromedriver.exe");       WebDriver driver = new ChromeDriver();       String url = "https://www.tutorialspoint.com/index.htm";       driver.get(url);       driver.manage().timeouts().implicitlyWait(12, TimeUnit.SECONDS);       // Javascript ऑब्जेक्ट তৈরি       JavascriptExecutor js = (JavascriptExecutor)driver;       // টেক্সট এক্সট্র্যাক্ট করার কমান্ড       String text = js.executeScript("return document.getElementById(' gsc-i-id1').value").toString();       System.out.println("Extracted text is" + text);       driver.close();    } }

  1. জাভাস্ক্রিপ্টে ইমেজের usemap অ্যাট্রিবিউটের মান কীভাবে পাবেন?

  2. জাভাস্ক্রিপ্টে স্ট্রিংয়ের প্রাইমিটিভ ভ্যালু পাওয়ার উপায়

  3. Tkinter-এ Entry উইজেটের মান পাওয়া

  4. ম্যাকেও Photos-এ ফটো আনার পদ্ধতি