本文整理匯總了Java中org.openqa.selenium.WebElement.sendKeys方法的典型用法代碼示例。如果您正苦於以下問題:Java WebElement.sendKeys方法的具體用法?Java WebElement.sendKeys怎麽用?Java WebElement.sendKeys使用的例子?那麽恭喜您, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.openqa.selenium.WebElement的用法示例。
在下文中一共展示了WebElement.sendKeys方法的19個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於我們的係統推薦出更棒的Java代碼示例。
示例1: searchFor
點讚 3
import org.openqa.selenium.WebElement; //導入方法依賴的package包/類
/**
* Types into the search bar in the top right and searches.
*
* @param content
* - The value to type into the search bar.
*/
public void searchFor(String content) {
this.focusForm(false);
WebElement mGTypeArea = _wait.until(ExpectedConditions.presenceOfElementLocated(By.name("sysparm_search")));
if (!mGTypeArea.getClass().toString().contains("focus")) {
WebElement magnifyingGlass = _wait
.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("[action='textsearch.do']")));
magnifyingGlass.click();
}
if(!mGTypeArea.getAttribute("value").equalsIgnoreCase("")) {
mGTypeArea.clear();
}
mGTypeArea.sendKeys(content);
mGTypeArea.sendKeys(Keys.ENTER);
}
開發者ID:SeanABoyer,項目名稱:ServiceNow_Selenium,代碼行數:21,
示例2: sendKeys
點讚 3
import org.openqa.selenium.WebElement; //導入方法依賴的package包/類
public void sendKeys() throws Throwable {
driver = new JavaDriver();
List buttons = driver.findElements(By.cssSelector("button"));
AssertJUnit.assertEquals(3, buttons.size());
WebElement b1 = buttons.get(0);
AssertJUnit.assertEquals("
WebElement b2 = buttons.get(1);
AssertJUnit.assertEquals("middle button", b2.getText());
WebElement b3 = buttons.get(2);
AssertJUnit.assertEquals("
AssertJUnit.assertEquals("true", b1.getAttribute("enabled"));
AssertJUnit.assertEquals("true", b2.getAttribute("enabled"));
AssertJUnit.assertEquals("false", b3.getAttribute("enabled"));
b1.sendKeys(Keys.SPACE);
AssertJUnit.assertEquals("false", b1.getAttribute("enabled"));
AssertJUnit.assertEquals("false", b2.getAttribute("enabled"));
AssertJUnit.assertEquals("true", b3.getAttribute("enabled"));
}
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:19,
示例3: sendKeys
點讚 3
import org.openqa.selenium.WebElement; //導入方法依賴的package包/類
public void sendKeys() throws Throwable {
driver = new JavaDriver();
List buttons = driver.findElements(By.cssSelector("button"));
AssertJUnit.assertEquals(3, buttons.size());
WebElement b1 = buttons.get(0);
AssertJUnit.assertEquals("Disable middle button", b1.getText());
WebElement b2 = buttons.get(1);
AssertJUnit.assertEquals("Middle button", b2.getText());
WebElement b3 = buttons.get(2);
AssertJUnit.assertEquals("Enable middle button", b3.getText());
AssertJUnit.assertEquals("true", b1.getAttribute("enabled"));
AssertJUnit.assertEquals("true", b2.getAttribute("enabled"));
AssertJUnit.assertEquals("false", b3.getAttribute("enabled"));
b1.sendKeys(Keys.SPACE);
AssertJUnit.assertEquals("false", b1.getAttribute("enabled"));
AssertJUnit.assertEquals("false", b2.getAttribute("enabled"));
AssertJUnit.assertEquals("true", b3.getAttribute("enabled"));
}
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:19,
示例4: testEventListenerWithError
點讚 2
import org.openqa.selenium.WebElement; //導入方法依賴的package包/類
@Test
public void testEventListenerWithError() {
WebDriver webDriver = rule.getWebDriver();
webDriver.get("https://github.com");
WebElement searchInput = webDriver.findElement(By.cssSelector(".header-search-input"));
searchInput.sendKeys("will", "test");
searchInput.sendKeys(Keys.ENTER);
String searchKeyword = webDriver.findElement(By.cssSelector(".header-search-input")).getAttribute("value");
assertThat(searchKeyword, is("foooooo"));
}
開發者ID:willhaben,項目名稱:willtest,代碼行數:11,
示例5: testGetAttribute
點讚 2
import org.openqa.selenium.WebElement; //導入方法依賴的package包/類
@Test
public void testGetAttribute() {
WebElement textField = driver.findElement(By.xpath("//TextField"));
textField.sendKeys("hello");
// TODO: Currently (Selenium 3.6) getAttribute delegates to
// executeJavaScript with a complex script which we can't support.
String enabled = textField.getAttribute("Enabled");
// assertEquals("true", enabled);
// assertEquals("Consolas", textField.getAttribute("Font"));
// assertEquals("false", textField.getAttribute("IsPassword"));
// assertEquals("MultiLine", textField.getAttribute("true"));
}
開發者ID:MicroFocus,項目名稱:SilkAppDriver,代碼行數:15,
示例6: sendKeysDelay
點讚 2
import org.openqa.selenium.WebElement; //導入方法依賴的package包/類
/**
* Send keys with delay
* @param element Element to send
* @param message Message to put
* @param delay Delay in ms
*/
public void sendKeysDelay(WebElement element, String message, long delay) {
for (char c : message.toCharArray()) {
element.sendKeys(String.valueOf(c));
try {
TimeUnit.MILLISECONDS.sleep(delay);
} catch (InterruptedException e) {
//its ok
}
}
}
開發者ID:brunocvcunha,項目名稱:seleneasy,代碼行數:19,
示例7: pressTabKey
點讚 2
import org.openqa.selenium.WebElement; //導入方法依賴的package包/類
/**
* Simulate Tab key
*/
@Override
@PublicAtsApi
public void pressTabKey() {
new RealHtmlElementState(this).waitToBecomeExisting();
WebElement element = RealHtmlElementLocator.findElement(this);
element.sendKeys(Keys.TAB);
}
開發者ID:Axway,項目名稱:ats-framework,代碼行數:13,
示例8: tableCellEditUneditable
點讚 2
import org.openqa.selenium.WebElement; //導入方法依賴的package包/類
public void tableCellEditUneditable() throws Throwable {
driver = new JavaDriver();
try {
WebElement cell = driver.findElement(By.cssSelector("table::mnth-cell(3,1)::editor"));
cell.sendKeys("Hello World", Keys.ENTER);
throw new MissingException(NoSuchElementException.class);
} catch (NoSuchElementException e) {
}
}
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:10,
示例9: sendKeysNTimes
點讚 2
import org.openqa.selenium.WebElement; //導入方法依賴的package包/類
public static void sendKeysNTimes(WebElement element, int numberOfTimes, Keys keyName) {
try {
for (int count = 1; count <= numberOfTimes; count++) {
element.sendKeys(keyName);
}
} catch (Exception e) {
System.out.println("Error occured while sending keys...\n" + e.getMessage());
}
}
開發者ID:anilpandeykiet,項目名稱:POM_HYBRID_FRAMEOWRK,代碼行數:10,
示例10: username_and_password_are_given
點讚 2
import org.openqa.selenium.WebElement; //導入方法依賴的package包/類
@When("^username \"([^\"]*)\" and password \"([^\"]*)\" are given$")
public void username_and_password_are_given(String username, String password) throws Throwable {
WebElement element = driver.findElement(By.name("username"));
element.sendKeys(username);
element = driver.findElement(By.name("password"));
element.sendKeys(password);
element = driver.findElement(By.name("login"));
element.submit();
}
開發者ID:mluukkai,項目名稱:ohjelmistotuotanto2017,代碼行數:10,
示例11: changeData
點讚 2
import org.openqa.selenium.WebElement; //導入方法依賴的package包/類
public void changeData(String value){
WebElement text = getDriver().findElement(By.id("form:text"));
WebElement button = getDriver().findElement(By.id("form:modify"));
text.clear();
text.sendKeys(value);
button.click();
waitForPageToLoad();
}
開發者ID:arcuri82,項目名稱:testing_security_development_enterprise_systems,代碼行數:11,
示例12: clickOnCol
點讚 2
import org.openqa.selenium.WebElement; //導入方法依賴的package包/類
private void clickOnCol(WebElement table, int colNum) {
// Index on the element is 1 based and index on the JTable is 0 based.
// Hence adding 1 to the colNum
WebElement col = table.findElement(By.cssSelector(".::mnth-cell(1," + (colNum + 1) + ")"));
col.click();
table.sendKeys(Keys.NULL);
}
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:8,
示例13: UpdateCV
點讚 2
import org.openqa.selenium.WebElement; //導入方法依賴的package包/類
public void UpdateCV (String filePath) {
WebElement viewProfile = driver.findElement (By.linkText ("View Profile"));
Actions act = new Actions(driver);
act.click (viewProfile).perform ();
WebElement uploadLink = driver.findElement (By.id ("uploadLink"));
act.click (uploadLink).perform ();
WebElement attachCV = driver.findElement (By.id("attachCV"));
attachCV.sendKeys (filePath);
sleep();
WebElement saveCV = driver.findElement (By.cssSelector("button.w85bt.fl"));
act.click(saveCV).perform ();
sleep();
}
開發者ID:mfaisalkhatri,項目名稱:NaukriSite,代碼行數:21,
示例14: setText
點讚 2
import org.openqa.selenium.WebElement; //導入方法依賴的package包/類
public void setText(String id, String text){
WebElement element = driver.findElement(By.id(id));
element.clear();
element.sendKeys(text);
}
開發者ID:arcuri82,項目名稱:testing_security_development_enterprise_systems,代碼行數:6,
示例15: setBucketName
點讚 2
import org.openqa.selenium.WebElement; //導入方法依賴的package包/類
public void setBucketName(String bucketName)
{
WebElement bucketNameInput = getBucketNameInput();
bucketNameInput.sendKeys(bucketName);
}
開發者ID:tmply,項目名稱:tmply,代碼行數:6,
示例16: cadastro
點讚 2
import org.openqa.selenium.WebElement; //導入方法依賴的package包/類
@Test
public void cadastro() throws InterruptedException {
WebDriverWait wait = new WebDriverWait(driver, 30);
wait.until(ExpectedConditions.presenceOfElementLocated(By.id("Name")));
WebElement name = driver.findElement(By.id("Name"));
name.sendKeys("Vitor Cardoso");
wait.until(ExpectedConditions.presenceOfElementLocated(By.id("Email")));
WebElement email = driver.findElement(By.id("Email"));
email.sendKeys(("[email protected]"));
wait.until(ExpectedConditions.presenceOfElementLocated(By.id("Site")));
WebElement site = driver.findElement(By.id("Site"));
site.sendKeys("www.doqconsulting.com.br");
wait.until(ExpectedConditions.presenceOfElementLocated(By.id("Subject")));
WebElement assunto = driver.findElement(By.id("Subject"));
assunto.sendKeys("Teste Selenium com assert");
wait.until(ExpectedConditions.presenceOfElementLocated(By.id("Message")));
WebElement message = driver.findElement(By.id("Message"));
message.sendKeys
("Gostaria de saber mais sobre a DOQ Consulting e como podemos ajudá-lo? Envie sua mensagem pelo site ou em nossas redes sociais.");
// SUBMIT AND ASSERT
name.submit();
String respname = name.getAttribute("value");
Assert.assertEquals(respname,"Vitor Cardoso");
email.submit();
String resp = email.getAttribute("value");
Assert.assertEquals(resp,"[email protected]");
site.submit();
String respsite = site.getAttribute("value");
Assert.assertEquals(respsite,"www.doqconsulting.com.br");
assunto.submit();
String respassunto = assunto.getAttribute("value");
Assert.assertEquals(respassunto,"Teste Selenium com assert");
message.submit();
String respmsg = message.getAttribute("value");
Assert.assertEquals(respmsg,
"Gostaria de saber mais sobre a DOQ Consulting e como podemos ajudá-lo? Envie sua mensagem pelo site ou em nossas redes sociais.");
wait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("button[class='btn btn-send']")));
WebElement sendclick = driver.findElement(By.cssSelector("button[class='btn btn-send']"));
sendclick.click(); /*Código comentado devido ao erro do webdriver com o firefox*/
// wait.until(ExpectedConditions.presenceOfElementLocated(By.className("col-sm-7 col-sm-offset-1")));
// WebElement validatemsg = driver.findElement(By.className("col-sm-7 col-sm-offset-1"));
// String test = validatemsg.getText();
// Assert.assertEquals(test," *Sua mensagem foi enviada com sucesso, logo mais um de nosso consultores irão avaliar o seu caso e entrar em contato. ");
}
開發者ID:vitorc,項目名稱:QA_Begin,代碼行數:60,
示例17: clearText
點讚 1
import org.openqa.selenium.WebElement; //導入方法依賴的package包/類
/**
* Update a html input text with "".
*
* @param pageElement
* Is target element
* @param keysToSend
* character to send to the element after {@link org.openqa.selenium.WebElement#sendKeys(CharSequence...) sendKeys} with textOrKey
* @param args
* list of arguments to format the found selector with
* @throws TechnicalException
* is thrown if you have a technical error (format, configuration, datas, ...) in NoraUi.
* Exception with {@value com.github.noraui.utils.Messages#FAIL_MESSAGE_ERROR_CLEAR_ON_INPUT} message (with screenshot, no exception)
* @throws FailureException
* if the scenario encounters a functional error
*/
protected void clearText(PageElement pageElement, CharSequence keysToSend, Object... args) throws TechnicalException, FailureException {
try {
WebElement element = Context.waitUntil(ExpectedConditions.presenceOfElementLocated(Utilities.getLocator(pageElement, args)));
element.clear();
if (keysToSend != null) {
element.sendKeys(keysToSend);
}
} catch (Exception e) {
new Result.Failure<>(e.getMessage(), Messages.format(Messages.getMessage(Messages.FAIL_MESSAGE_ERROR_CLEAR_ON_INPUT), pageElement, pageElement.getPage().getApplication()), true,
pageElement.getPage().getCallBack());
}
}
開發者ID:NoraUi,項目名稱:NoraUi,代碼行數:28,
示例18: enterIntoFieldWithId
點讚 1
import org.openqa.selenium.WebElement; //導入方法依賴的package包/類
/**
* Enters the specified text into the field.
*
Note: This is a low-level way to locate the field. Please only use this method if the text input
* doesn't have a corresponding label, otherwise use the enterIntoField(String,String)
method using
* the label text to identify the field.
* @param text The text to enter
* @param id The field id
*/
public void enterIntoFieldWithId(String text, String id) {
WebElement textElement = webDriver.findElement(By.id(id));
textElement.clear();
textElement.sendKeys(text);
}
開發者ID:dvsa,項目名稱:mot-automated-testsuite,代碼行數:14,
示例19: writeValue
點讚 1
import org.openqa.selenium.WebElement; //導入方法依賴的package包/類
/**
* Takes the given value as input for the element with the given id.
*
* @param id
* the element id
* @param value
* the input value
* @throws NoSuchElementException
* if element is not present
*/
public void writeValue(String id, String value) {
WebElement element = driver.findElement(By.id(id));
element.sendKeys(value);
}
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:15,
注:本文中的org.openqa.selenium.WebElement.sendKeys方法示例整理自Github/MSDocs等源碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。