-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Expand file tree
/
Copy pathInputTest.cs
More file actions
97 lines (76 loc) · 2.97 KB
/
Copy pathInputTest.cs
File metadata and controls
97 lines (76 loc) · 2.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium;
using OpenQA.Selenium.Support.UI;
namespace SeleniumDocs.BiDi.W3C
{
[TestClass]
public class InputTest : BaseFirefoxTest
{
[TestMethod]
public void PerformKeyActions()
{
driver.Url = "https://www.selenium.dev/selenium/web/single_text_input.html";
var input = driver.FindElement(By.Id("textInput"));
input.SendKeys("Hello World");
Assert.AreEqual("Hello World", input.GetAttribute("value"));
}
[TestMethod]
public void PerformMouseActions()
{
driver.Url = "https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html";
var button = driver.FindElement(By.Id("consoleLog"));
button.Click();
// Verify action occurred
var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(5));
Assert.IsNotNull(button);
}
[TestMethod]
public void DispatchKeyboardEvents()
{
driver.Url = "https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html";
var element = driver.FindElement(By.TagName("body"));
((IJavaScriptExecutor)driver).ExecuteScript(@"
document.addEventListener('keydown', function(e) {
console.log('Key pressed: ' + e.key);
});
");
element.SendKeys("a");
}
[TestMethod]
public void DispatchMouseEvents()
{
driver.Url = "https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html";
var button = driver.FindElement(By.Id("consoleLog"));
((IJavaScriptExecutor)driver).ExecuteScript(@"
arguments[0].addEventListener('mouseover', function(e) {
console.log('Mouse over');
});
", button);
button.Click();
}
[TestMethod]
public void DispatchTouchEvents()
{
driver.Url = "https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html";
var element = driver.FindElement(By.TagName("body"));
((IJavaScriptExecutor)driver).ExecuteScript(@"
document.addEventListener('touchstart', function(e) {
console.log('Touch started');
});
");
}
[TestMethod]
public void DispatchWheelEvents()
{
driver.Url = "https://www.selenium.dev/selenium/web/iframes.html";
((IJavaScriptExecutor)driver).ExecuteScript(@"
window.addEventListener('wheel', function(e) {
console.log('Wheel event');
});
");
}
}
}