|
10 | 10 |
|
11 | 11 | import org.openqa.selenium.Alert; |
12 | 12 | import org.openqa.selenium.JavascriptExecutor; |
13 | | -import org.openqa.selenium.Keys; |
14 | 13 | import org.openqa.selenium.NoAlertPresentException; |
15 | 14 | import org.openqa.selenium.NoSuchElementException; |
16 | 15 | import org.openqa.selenium.OutputType; |
17 | 16 | import org.openqa.selenium.TakesScreenshot; |
18 | 17 | import org.openqa.selenium.WebDriver; |
19 | 18 | import org.openqa.selenium.WebElement; |
20 | | -import org.openqa.selenium.interactions.Actions; |
21 | 19 | import org.openqa.selenium.support.ui.ExpectedConditions; |
22 | 20 | import org.openqa.selenium.support.ui.WebDriverWait; |
23 | 21 | import org.slf4j.Logger; |
@@ -175,53 +173,4 @@ public void captureScreenshot(String filename) { |
175 | 173 | LOGGER.error("Failed to capture screenshot: {}", e.getMessage()); |
176 | 174 | } |
177 | 175 | } |
178 | | - |
179 | | - public void enterTextJS(WebElement element, String text) { |
180 | | - try { |
181 | | - waitForElementVisible(element); |
182 | | - |
183 | | - ((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView({block: 'center'});", element); |
184 | | - new Actions(driver).moveToElement(element).click().perform(); |
185 | | - ((JavascriptExecutor) driver).executeScript("arguments[0].value = '';", element); |
186 | | - |
187 | | - Actions actions = new Actions(driver); |
188 | | - for (char c : text.toCharArray()) { |
189 | | - actions.sendKeys(String.valueOf(c)).pause(Duration.ofMillis(150)); |
190 | | - } |
191 | | - actions.perform(); |
192 | | - |
193 | | - ((JavascriptExecutor) driver).executeScript( |
194 | | - "arguments[0].dispatchEvent(new Event('input', { bubbles: true }));" + |
195 | | - "arguments[0].dispatchEvent(new Event('change', { bubbles: true }));" + |
196 | | - "arguments[0].blur();", |
197 | | - element |
198 | | - ); |
199 | | - |
200 | | - String finalValue = element.getAttribute("value"); |
201 | | - if (finalValue == null) { |
202 | | - throw new RuntimeException("Value was rejected by frontend (null)."); |
203 | | - } |
204 | | - } |
205 | | - |
206 | | - catch (Exception e) { |
207 | | - throw new RuntimeException("Failed to set filedvalue due to UI behavior", e); |
208 | | - } |
209 | | - } |
210 | | - |
211 | | - public String getElementValue(WebElement element) { |
212 | | - waitForElementVisible(element); |
213 | | - return element.getAttribute("value"); |
214 | | - } |
215 | | - |
216 | | - public String getElementAttribute(WebElement element, String attribute) { |
217 | | - waitForElementVisible(element); |
218 | | - return element.getAttribute(attribute); |
219 | | - } |
220 | | - |
221 | | - public void clearField(WebElement element) { |
222 | | - waitForElementVisible(element); |
223 | | - element.click(); |
224 | | - element.sendKeys(Keys.CONTROL + "a"); |
225 | | - element.sendKeys(Keys.DELETE); |
226 | | - } |
227 | 176 | } |
0 commit comments