'Using Selenium to Click and Drag Across the Window to Highlight Text on the Web Page

I am trying to move the cursor to an element, then click and drag across the screen to simulate someone highlighting text on the screen. My code does not appear to be simulating this action though. Initially, I expect the cursor to move to the element indicated but this is not occurring. I don't see the cursor moving and nothing gets highlighted.

from selenium.common.exceptions import NoSuchElementException
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
import time
from selenium.webdriver.common.action_chains import ActionChains
textreal_listing=[]
browser = webdriver.Chrome(r'\\homedirpva1a01\USERSNC$\603225\chromedriver\chromedriver.exe')
actions = ActionChains(browser)
time.sleep(5)


browser.get("https://www.nj.gov/dobi/division_insurance/bfd/enforcement2020.html")
time.sleep(5)
element = browser.find_element_by_xpath("/html/body/div/div/table[2]/tbody/tr/td/table/tbody/tr[2]/td[3]/table/tbody/tr[5]/td/p[1]/strong[1]")
time.sleep(5)
actions.move_to_element(element)
time.sleep(1)
actions.click_and_hold(on_element=None)
time.sleep(1)
actions.move_by_offset(550, 320).perform()
time.sleep(1)
actions.release()
actions.perform()


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source