本文整理了Java中org.openqa.selenium.Alert.sendKeys()
方法的一些代码示例,展示了Alert.sendKeys()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Alert.sendKeys()
方法的具体详情如下:
包路径:org.openqa.selenium.Alert
类名称:Alert
方法名:sendKeys
暂无
代码示例来源:origin: selenide/selenide
public String prompt(String expectedDialogText, String inputText) {
Alert alert = driver.switchTo().alert();
String actualDialogText = alert.getText();
if (inputText != null)
alert.sendKeys(inputText);
alert.accept();
checkDialogText(driver, expectedDialogText, actualDialogText);
return actualDialogText;
}
代码示例来源:origin: stackoverflow.com
javascriptprompt.sendKeys("This is Selenium Training");
代码示例来源:origin: appium/java-client
protected boolean assertThatAlertListenerWorks(EmptyWebDriver driver, TestListener listener, String prefix) {
try {
Alert alert = driver.switchTo().alert();
alert.accept();
alert.dismiss();
alert.sendKeys("Keys");
assertThat(listener.messages,
contains(prefix + "Attempt to accept alert",
prefix + "The alert was accepted",
prefix + "Attempt to dismiss alert",
prefix + "The alert was dismissed",
prefix + "Attempt to send keys to alert",
prefix + "Keys were sent to alert"));
return true;
} finally {
listener.messages.clear();
}
}
代码示例来源:origin: org.mazarineblue/MazarineBlue-WebDriver
@Override
public void type(String text) {
alert.sendKeys(text);
}
代码示例来源:origin: io.github.aktoluna/slnarch-core
public void sendKeys(String keysToSend) {
alert.sendKeys(keysToSend);
}
}
代码示例来源:origin: appium/java-client
@Test
public void alertEventTest() {
try {
Alert alert = driver.switchTo().alert();
alert.accept();
alert.dismiss();
alert.sendKeys("Keys");
assertThat(listener.messages,
hasItems(WEBDRIVER_EVENT_LISTENER + "Attempt to accept alert",
WEBDRIVER_EVENT_LISTENER + "The alert was accepted",
WEBDRIVER_EVENT_LISTENER + "Attempt to dismiss alert",
WEBDRIVER_EVENT_LISTENER + "The alert was dismissed"));
} finally {
listener.messages.clear();
}
}
代码示例来源:origin: stackoverflow.com
Alert alert1=driver.switchTo().alert();
alert1.sendKeys("Hello");
alert1.accept();
代码示例来源:origin: stackoverflow.com
Alert prompt = driver.switchTo().alert();
// Get message in Alert pop up
message = prompt.getText();
System.out.println("Prompt pop up message :- " + message);
// Force the program to wait to view the dialog box
try{Thread.sleep(4000);}catch(Exception e){System.out.println(e.toString());}
// Type value in prompt dialog box
prompt.sendKeys("Akshay Kumar");
// Force the program to wait to view the dialog box
try{Thread.sleep(4000);}catch(Exception e){System.out.println(e.toString());}
// Click on Ok button
prompt.accept();
代码示例来源:origin: viltgroup/minium
@Override
protected void doPerform() {
alert().sendKeys(keys);
}
}.perform();
代码示例来源:origin: stackoverflow.com
Robot robot = new Robot();
Alert alert=dr.switchTo().alert();
dr.get("the url");
alert.sendKeys("username");
//dr.switchTo().alert();
robot.keyPress(KeyEvent.VK_TAB);
alert.sendKeys("password");
alert.accept();
代码示例来源:origin: persado/stevia
@Override
public void promptInputPressOK(String inputMessage) {
Alert alert = waitForAlert();
alert.sendKeys(inputMessage);
alert.accept();
}
代码示例来源:origin: persado/stevia
@Override
public void promptInputPressCancel(String inputMessage) {
Alert alert = waitForAlert();
alert.sendKeys(inputMessage);
alert.dismiss();
}
代码示例来源:origin: vmi/selenese-runner-java
@Override
public void actionPerformed(Alert alert) {
if (answer != null)
alert.sendKeys(answer);
if (accept)
alert.accept();
else
alert.dismiss();
// reset the behavior
this.answer = null;
this.accept = true;
}
};
代码示例来源:origin: vmi/selenese-runner-java
@Override
public void actionPerformed(Alert alert) {
if (answer != null) {
alert.sendKeys(answer);
}
if (accept) {
alert.accept();
} else {
alert.dismiss();
}
// reset the behavior
this.answer = null;
this.accept = true;
}
}
代码示例来源:origin: stackoverflow.com
// wait for the window to appear
WebDriverWait wait = new WebDriverWait(driver, 10);
wait.until(ExpectedConditions.alertIsPresent());
// switch to the file upload window
Alert alert = driver.switchTo().alert();
// enter the filename
alert.sendKeys(fileName);
// hit enter
Robot r = new Robot();
r.keyPress(KeyEvent.VK_ENTER);
r.keyRelease(KeyEvent.VK_ENTER);
// switch back
driver.switchTo().activeElement();
代码示例来源:origin: stackoverflow.com
// working with alerts.
Alert alert = driver.switchTo().alert();
// for clicking on ok button
alert.accept();
// for clicking on cancel button
alert.dismiss();
// for getting alert text message
alert.getText();
// for sending some text inside the alert
alert.sendKeys("alert string");
代码示例来源:origin: com.epam.jdi/jdi-light
@JDIAction("Input '{0}' in alert and accept")
public static void sendKeysInAlert(String text) {
alert().sendKeys(text);
alert().accept();
}
代码示例来源:origin: jenkinsci/acceptance-test-harness
/**
* Adds a new user/group to this matrix.
*/
public MatrixRow addUser(String name) {
this.name.resolve().findElement(by.parent()).findElement(by.button("Add user or group…")).click();
WebDriverWait wait = new WebDriverWait(driver, 10);
Alert promptAlert = wait.until(ExpectedConditions.alertIsPresent());
promptAlert.sendKeys(name);
promptAlert.accept();
return getUser(name);
}
代码示例来源:origin: jenkinsci/acceptance-test-harness
/**
* Adds a new user/group to this matrix.
*/
public MatrixRow addUser(String name) {
this.name.resolve().findElement(by.parent()).findElement(by.button("Add user or group…")).click();
WebDriverWait wait = new WebDriverWait(driver, 10);
Alert promptAlert = wait.until(ExpectedConditions.alertIsPresent());
promptAlert.sendKeys(name);
promptAlert.accept();
return getUser(name);
}
代码示例来源:origin: com.saucelabs/sebuilder-interpreter
@Override
public boolean run(TestRun ctx) {
ctx.driver().switchTo().alert().sendKeys(ctx.string("text"));
ctx.driver().switchTo().alert().accept();
return true;
}
}
内容来源于网络,如有侵权,请联系作者删除!