Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6117261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:18:01+00:00 2026-05-23T15:18:01+00:00

I want to use WebDriver to select a line of text in browser screen(actually

  • 0

I want to use WebDriver to select a line of text in browser screen(actually in CKEditor editing area) then change its text style from CKEditor toolbar. Any method can do that?

For example, a line with html code like below:

this is a sample line.

I try to use Actions to build a mouse action chain but no success due to not familiar with that. Thanks for any hints or answer.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T15:18:02+00:00Added an answer on May 23, 2026 at 3:18 pm

    I’m not sure this is actually possible with WebDriver. What you would want to do is to clickAndHold(...).moveByOffset(...).release(...). Unforunately, WebDriver only allows a WebElement as a parameter to clickAndHold().

    My best advice to you is to emulate JavaScript events for this. You can then do something like this in your test:

    ((JavascriptExecutor) driver).executeScript(...);
    

    I wrote code for emulating mouse events which I use with some of my Selenium tests. Although it doesn’t do exactly what you want, hopefully it will be useful (hopefully you can just set the x/y coords and perhaps that will get it working):

    var f = function() {
      var id  = "ext-gen1116";
      var top = document.querySelector( '#ext-gen1116:nthchild(0)' );
      var bot = document.getElementById( id ).childNodes[3];
    
      var getX = function( obj ) {
        if( obj == null ) {
          return 0;
        } else {
          return obj.offsetLeft + getX( obj.offsetParent );
        }
      }
    
      var getY = function( obj ) {
        if( obj == null ) {
          return 0;
        } else {
          return obj.offsetTop + getY( obj.offsetParent );
        }
      }
    
      var evt = document.createEvent("MouseEvents");
      evt.initMouseEvent("mousedown", true, true, window,
        0, 0, 0, 0, 0, false, false, false, false, 0, null);
      bot.dispatchEvent(evt);
    
      evt = document.createEvent("MouseEvents");
      evt.initMouseEvent("mousemove", true, true, window,
        0, 0, 0, getX( top ) - getX( bot ), getY( top ) - getY( bot ),
        false, false, false, false, 0, null);
      bot.dispatchEvent(evt);
    
      var mouseup = function( elem ) {
        var evt = document.createEvent("MouseEvents");
        evt.initMouseEvent("mouseup", true, true, window,
          0, 0, 0, 0, 0, false, false, false, false, 0, null);
        elem.dispatchEvent(evt);
      }
    
      setTimeout( mouseup, 500, bot );
    };
    f();
    

    If it’s possible for you to do what you want with the keyboard instead, this is by far the better solution. You can simply do driver.sendKeys(...). The Keys enum will be priceless for you in this case 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want use task_for_pid() and attach to another process and then change its memory
I'm using Selenium WebDriver with Java. I want to use Safari browser. Does Selenium
Hello all I am using webdriver so if I want to use selenium;s rc
i want use select statement on the a table and inserting result into a
I want to use Selenium WebDriver to find an element on a page. The
We recently started to use WebDriver (in favor of Selenium 1) for performing browser
I want to use Chrome in my Test on Webdriver + Ruby to download
I want to use Arquillian's Drone extension to configure WebDriver for some functional tests,
I am using Selenium WebDriver with Java & TestNG framework. I want to use
I use Selenium WebDriver. I open the first page then open the second page

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.