MCPcopy Create free account
hub / github.com/GCWing/BitFun / typeMessage

Method typeMessage

tests/e2e/page-objects/components/ChatInput.ts:91–139  ·  view source on GitHub ↗
(message: string)

Source from the content-addressed store, hash-verified

89 }
90
91 async typeMessage(message: string): Promise<void> {
92 const input = await this.findTextarea();
93 if (input) {
94 // For contentEditable elements, we need to use a different approach
95 const isContentEditable = await input.getAttribute('contenteditable');
96
97 if (isContentEditable === 'true') {
98 // Click to focus first
99 await input.click();
100 await browser.pause(200);
101
102 // Clear existing content first
103 await browser.keys([this.getSelectAllModifier(), 'a']);
104 await browser.pause(100);
105 await browser.keys(['Backspace']);
106 await browser.pause(100);
107
108 // Type the message, handling newlines
109 if (message.includes('\n')) {
110 // For multiline, split by newline and type with Shift+Enter
111 const lines = message.split('\n');
112 for (let i = 0; i < lines.length; i++) {
113 for (const char of lines[i]) {
114 await browser.keys([char]);
115 await browser.pause(10);
116 }
117 // Add newline except after last line
118 if (i < lines.length - 1) {
119 await browser.keys(['Shift', 'Enter']);
120 await browser.pause(50);
121 }
122 }
123 } else {
124 // Single line - type character by character
125 for (const char of message) {
126 await browser.keys([char]);
127 await browser.pause(10);
128 }
129 }
130 await browser.pause(200);
131 } else {
132 // Regular textarea
133 await input.setValue(message);
134 await browser.pause(200);
135 }
136 } else {
137 throw new Error('Chat input element not found');
138 }
139 }
140
141 async getValue(): Promise<string> {
142 const input = await this.findTextarea();

Callers 3

sendMessageMethod · 0.95
sendMessageWithEnterMethod · 0.95

Calls 5

findTextareaMethod · 0.95
getSelectAllModifierMethod · 0.95
clickMethod · 0.80
pauseMethod · 0.80
includesMethod · 0.80

Tested by

no test coverage detected