2016-11-14 7 views

答えて

-1

はい、あります。キーを使用して、テキストボックスにテキストを挿入することができます。しかし、テキストボックスに値を挿入する前に、テキストボックスの直前にある要素を調べてから、テキストボックスにジャンプするためにタブボタンを押す必要があります。

検査要素のロケータ値:

d.findElement(By.xpath("")).sendKeys(Keys.TAB,"enter your text"); 

入力したテキストは、テキストボックスに挿入されます。

1

また

JavascriptExecutor js = (JavascriptExecutor) driver; 
js.executeScript("document.getElementById('someid').value=arguments[0]","text to be inserted in input box"); 
1

あなたは、この場合にJavascriptExecutorを使用して試すことができ、同じことを行うためにJavascriptExecutorを使用することができます。

などについて。入力するテキストはGoogleの検索テキストフィールドに、次のコードは動作するはずです:

WebDriver driver = new FirefoxDriver(); 
driver.get("http://www.google.com"); 
JavascriptExecutor jse = (JavascriptExecutor) driver; 
jse.executeScript("document.getElementById('gbqfq').value = 'Ripon Al Wasim';"); 

REFのURL:How to input a value in a text field/box by using JavasSript in Selenium WebDriver

0

たぶん、このスクリプトを試してみてください。

WebDriverWait wait = new WebDriverWait(driver, 1);   
wait.until(ExpectedConditions.elementToBeClickable(By.id("element's id here"))).click(); 
wait.until(ExpectedConditions.presenceOfElementLocated(By.id("element's id here"))).sendKeys("enter text you want to put in"); 
関連する問題