简体   繁体   中英

How can i select text from one document using selenium webdriver

Suppose i have one document then how can i select text from that document using Selenium WebDriver .

I have entered below code:

d1.findElementByClassName("odd").click();
Thread.sleep(5000);
d1.manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS);
WebElement el = d1.findElement(By.id("doc-content"));
Actions act = new Actions(d1);
act.clickAndHold(el).build().perform();
act.release().perform();
act.doubleClick(el).build().perform();
act.clickAndHold(el).build().perform();
WebElement el1 = d1.findElement(By.id("doc-data"));
act.moveToElement(el1, 50, 50).build().perform();
act.dragAndDropBy(el, 100, 150).build().perform();
act.release().build().perform();

If I understand correctly you want to Highlight found element, you can try to run js to change style for that element:

WebElement element = driver.FindElement(By.Id('someId'));
((JavascriptExecutor) driver).executeScript("arguments[0].style.backgroundColor='yellow';", element);

Or change font color:

((JavascriptExecutor) driver).executeScript("arguments[0].style.color='yellow';", element);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM