12219

C# equivalent to Java Robot class

<h3>Question</h3>

What is the C# equivalent to Java Robot class for mouse pointer movements? As Actions class cannot be used directly for keyboard and mouse. I need to move my mouse pointer visually in selenium n c#. For example, if I want to access my mail from Rediffmail website, the mouse pointer should move to the address bar then to username and password textbox and log-in button. Mouse pointer should move along with the actions being performed in my tests.


<h3>Answer1:</h3>

As you are looking out for C# modules equivalent to Java Robot class there can be three possible solutions :

<ul><li>

If you can tweak your requirement form <em>move the mouse pointer visually</em> to <em>highlight the username and password textbox</em>, you can take help of ExecuteScript Method from IJavaScriptExecutor Interface as follows :

IWebElement element = driver.FindElement(By.XPath("username_field_xpath")) ((IJavaScriptExecutor)driver).ExecuteScript("arguments[0].setAttribute('style','backgroud: yellow; border: solid 2px red')", element); </li> <li>

Another alternative would be to use the Windows Input Simulator (C# SendInput Wrapper - Simulate Keyboard and Mouse) as @Nish26 mentioned in her comments.

</li> <li>The other alternative is the Global Mouse and Keyboard Library which uses the <em>Global Hooks</em> which can capture mouse and keyboard events from any application. These events are very similar to the ones that appear on Windows controls.</li> </ul>

For the second and third options you won't find a direct way to interact through <em>WebDriver</em>. Perhaps you have to lookout for a tailor-made solution.

来源:https://stackoverflow.com/questions/49511160/c-sharp-equivalent-to-java-robot-class

Recommend

  • How to find which delimiter was used during string split (VB.NET)
  • Odd Generic Inheritance pattern
  • If x in array in Java [duplicate]
  • Styling a funnel stack layout using native CSS and HTML
  • Removing disk from zfs pool permanently
  • tesseract didn't get the little labels
  • How does a JPA provider access (private) field values when no getter/setter method are defined?
  • format of ByteArray returned from C is invalid
  • Use tornado future to fetch url, two different ways get different results
  • Issue binding to ListBox WP7
  • How to add cropVariants to an image field in TYPO3 flexform
  • How can I pull data (JSON) from a clicked ng-repeat item to load a new, item specific page using $st
  • Implicit resolution with covariance
  • Generate Quartz Cron Expression Every 2nd monday/friday
  • How to store confidential PDF documents (file system vs. SQL) if we only use forms authentication
  • NServiceBus How To Publish Message From 2 Physical Locations Of 1 Logical Service
  • problems using replaceText for special characters: [ ]
  • 30 tables with few rows - TRUNCATE the fastest way to empty them and reset attached sequences?
  • Dynamically create controls in android using Kotlin
  • Progress bar shadow only on filled part
  • Merge of sorted lists with sized types
  • Get method parameters with specific annotation in aspect in scala using java reflection
  • Scrapy + Splash: scraping element inside inner html
  • How do I force ASP.NET Ajax to use a script from the FS and not WebResource.axd, or to reduce its HT
  • How to map a native query to POJO class using jpa and hibernate
  • How to detect beginning of line, or: “The name 'getCharPositionInLine' does not exist in t
  • How to add blur effect into UIImage with Swift? [duplicate]
  • How do I convert between time formats?
  • Implementing and using MinMax with four in row (connect4) game
  • programatically send a form with POST
  • can you use embedded ruby in custom javascript files in rails?
  • How to organize this layout with overflows?
  • view details for exception in vs 2017
  • How to use array in autohotkey?
  • Generate and export point cloud from Project Tango
  • how to specify different css for ie
  • How can i move Clearcase dyamic/snapshot views to another host (Linux)
  • JavaScript Regex to Match Boundaries of Words with diacritics
  • How to turn off notice reporting in xampp?
  • How to use Streams api peek() function and make it work?