Is there any other way(not sendKeys) to enter text into textbox using selenium webdriver?
Is there any other way(not sendKeys) to enter text into textbox using selenium webdriver ?
java selenium-webdriver
add a comment |
Is there any other way(not sendKeys) to enter text into textbox using selenium webdriver ?
java selenium-webdriver
3
Why would there be another way? What is the problem with sendKeys? API designers rarely provide 5 methods doing the same thing.
– JB Nizet
Nov 16 '14 at 8:49
One interviewer asked this question...
– Vasantha
Nov 16 '14 at 10:00
add a comment |
Is there any other way(not sendKeys) to enter text into textbox using selenium webdriver ?
java selenium-webdriver
Is there any other way(not sendKeys) to enter text into textbox using selenium webdriver ?
java selenium-webdriver
java selenium-webdriver
edited Nov 16 '14 at 10:01
Anirudh
1,32322150
1,32322150
asked Nov 16 '14 at 8:44
VasanthaVasantha
1212310
1212310
3
Why would there be another way? What is the problem with sendKeys? API designers rarely provide 5 methods doing the same thing.
– JB Nizet
Nov 16 '14 at 8:49
One interviewer asked this question...
– Vasantha
Nov 16 '14 at 10:00
add a comment |
3
Why would there be another way? What is the problem with sendKeys? API designers rarely provide 5 methods doing the same thing.
– JB Nizet
Nov 16 '14 at 8:49
One interviewer asked this question...
– Vasantha
Nov 16 '14 at 10:00
3
3
Why would there be another way? What is the problem with sendKeys? API designers rarely provide 5 methods doing the same thing.
– JB Nizet
Nov 16 '14 at 8:49
Why would there be another way? What is the problem with sendKeys? API designers rarely provide 5 methods doing the same thing.
– JB Nizet
Nov 16 '14 at 8:49
One interviewer asked this question...
– Vasantha
Nov 16 '14 at 10:00
One interviewer asked this question...
– Vasantha
Nov 16 '14 at 10:00
add a comment |
3 Answers
3
active
oldest
votes
Any other way is only to use native Javascript action to enter the value in the text box:
WebDriver driver = new FirefoxDriver();
JavascriptExecutor executor = (JavascriptExecutor)driver;
executor.executeScript("document.getElementById("textbox_id").value='new value';);
I'm getting error like this... Exception in thread "main" org.openqa.selenium.WebDriverException: document.getElementById(...) is null Command duration or timeout: 31 milliseconds.Can you tell me the solution please ?
– Vasantha
Nov 16 '14 at 12:26
Which version of firefox and webdriver are you using?
– Anirudh
Nov 16 '14 at 13:44
Firefox version is 33.1 and webdriver version is 2.44.0
– Vasantha
Nov 16 '14 at 14:02
add a comment |
@Vasntha, try mine code its tested one
driver.get("http://www.qajudge.com/");
WebElement cssValue= driver.findElement(By.xpath(".//*[@id='s']"));
JavascriptExecutor jse = (JavascriptExecutor) driver;
jse.executeScript("document.getElementById('s').value='Virender Testing
sending'");
add a comment |
WebElement name=driver.findElement(By.name("username"));
((JavascriptExecutor)driver).executeAsyncScript("arguments[0].value='admin'",name);
2
Welcome to stack overflow :-) code-only answers aren't useful for the community. Please look at How to Answer
– JimHawkins
Jul 13 '17 at 10:45
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f26955263%2fis-there-any-other-waynot-sendkeys-to-enter-text-into-textbox-using-selenium-w%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
Any other way is only to use native Javascript action to enter the value in the text box:
WebDriver driver = new FirefoxDriver();
JavascriptExecutor executor = (JavascriptExecutor)driver;
executor.executeScript("document.getElementById("textbox_id").value='new value';);
I'm getting error like this... Exception in thread "main" org.openqa.selenium.WebDriverException: document.getElementById(...) is null Command duration or timeout: 31 milliseconds.Can you tell me the solution please ?
– Vasantha
Nov 16 '14 at 12:26
Which version of firefox and webdriver are you using?
– Anirudh
Nov 16 '14 at 13:44
Firefox version is 33.1 and webdriver version is 2.44.0
– Vasantha
Nov 16 '14 at 14:02
add a comment |
Any other way is only to use native Javascript action to enter the value in the text box:
WebDriver driver = new FirefoxDriver();
JavascriptExecutor executor = (JavascriptExecutor)driver;
executor.executeScript("document.getElementById("textbox_id").value='new value';);
I'm getting error like this... Exception in thread "main" org.openqa.selenium.WebDriverException: document.getElementById(...) is null Command duration or timeout: 31 milliseconds.Can you tell me the solution please ?
– Vasantha
Nov 16 '14 at 12:26
Which version of firefox and webdriver are you using?
– Anirudh
Nov 16 '14 at 13:44
Firefox version is 33.1 and webdriver version is 2.44.0
– Vasantha
Nov 16 '14 at 14:02
add a comment |
Any other way is only to use native Javascript action to enter the value in the text box:
WebDriver driver = new FirefoxDriver();
JavascriptExecutor executor = (JavascriptExecutor)driver;
executor.executeScript("document.getElementById("textbox_id").value='new value';);
Any other way is only to use native Javascript action to enter the value in the text box:
WebDriver driver = new FirefoxDriver();
JavascriptExecutor executor = (JavascriptExecutor)driver;
executor.executeScript("document.getElementById("textbox_id").value='new value';);
answered Nov 16 '14 at 9:08
AnirudhAnirudh
1,32322150
1,32322150
I'm getting error like this... Exception in thread "main" org.openqa.selenium.WebDriverException: document.getElementById(...) is null Command duration or timeout: 31 milliseconds.Can you tell me the solution please ?
– Vasantha
Nov 16 '14 at 12:26
Which version of firefox and webdriver are you using?
– Anirudh
Nov 16 '14 at 13:44
Firefox version is 33.1 and webdriver version is 2.44.0
– Vasantha
Nov 16 '14 at 14:02
add a comment |
I'm getting error like this... Exception in thread "main" org.openqa.selenium.WebDriverException: document.getElementById(...) is null Command duration or timeout: 31 milliseconds.Can you tell me the solution please ?
– Vasantha
Nov 16 '14 at 12:26
Which version of firefox and webdriver are you using?
– Anirudh
Nov 16 '14 at 13:44
Firefox version is 33.1 and webdriver version is 2.44.0
– Vasantha
Nov 16 '14 at 14:02
I'm getting error like this... Exception in thread "main" org.openqa.selenium.WebDriverException: document.getElementById(...) is null Command duration or timeout: 31 milliseconds.Can you tell me the solution please ?
– Vasantha
Nov 16 '14 at 12:26
I'm getting error like this... Exception in thread "main" org.openqa.selenium.WebDriverException: document.getElementById(...) is null Command duration or timeout: 31 milliseconds.Can you tell me the solution please ?
– Vasantha
Nov 16 '14 at 12:26
Which version of firefox and webdriver are you using?
– Anirudh
Nov 16 '14 at 13:44
Which version of firefox and webdriver are you using?
– Anirudh
Nov 16 '14 at 13:44
Firefox version is 33.1 and webdriver version is 2.44.0
– Vasantha
Nov 16 '14 at 14:02
Firefox version is 33.1 and webdriver version is 2.44.0
– Vasantha
Nov 16 '14 at 14:02
add a comment |
@Vasntha, try mine code its tested one
driver.get("http://www.qajudge.com/");
WebElement cssValue= driver.findElement(By.xpath(".//*[@id='s']"));
JavascriptExecutor jse = (JavascriptExecutor) driver;
jse.executeScript("document.getElementById('s').value='Virender Testing
sending'");
add a comment |
@Vasntha, try mine code its tested one
driver.get("http://www.qajudge.com/");
WebElement cssValue= driver.findElement(By.xpath(".//*[@id='s']"));
JavascriptExecutor jse = (JavascriptExecutor) driver;
jse.executeScript("document.getElementById('s').value='Virender Testing
sending'");
add a comment |
@Vasntha, try mine code its tested one
driver.get("http://www.qajudge.com/");
WebElement cssValue= driver.findElement(By.xpath(".//*[@id='s']"));
JavascriptExecutor jse = (JavascriptExecutor) driver;
jse.executeScript("document.getElementById('s').value='Virender Testing
sending'");
@Vasntha, try mine code its tested one
driver.get("http://www.qajudge.com/");
WebElement cssValue= driver.findElement(By.xpath(".//*[@id='s']"));
JavascriptExecutor jse = (JavascriptExecutor) driver;
jse.executeScript("document.getElementById('s').value='Virender Testing
sending'");
answered Mar 29 '15 at 11:58
Virender SinghVirender Singh
11
11
add a comment |
add a comment |
WebElement name=driver.findElement(By.name("username"));
((JavascriptExecutor)driver).executeAsyncScript("arguments[0].value='admin'",name);
2
Welcome to stack overflow :-) code-only answers aren't useful for the community. Please look at How to Answer
– JimHawkins
Jul 13 '17 at 10:45
add a comment |
WebElement name=driver.findElement(By.name("username"));
((JavascriptExecutor)driver).executeAsyncScript("arguments[0].value='admin'",name);
2
Welcome to stack overflow :-) code-only answers aren't useful for the community. Please look at How to Answer
– JimHawkins
Jul 13 '17 at 10:45
add a comment |
WebElement name=driver.findElement(By.name("username"));
((JavascriptExecutor)driver).executeAsyncScript("arguments[0].value='admin'",name);
WebElement name=driver.findElement(By.name("username"));
((JavascriptExecutor)driver).executeAsyncScript("arguments[0].value='admin'",name);
edited Jul 13 '17 at 7:58
Bugs
4,14992536
4,14992536
answered Jul 13 '17 at 6:05
jagannathjagannath
1
1
2
Welcome to stack overflow :-) code-only answers aren't useful for the community. Please look at How to Answer
– JimHawkins
Jul 13 '17 at 10:45
add a comment |
2
Welcome to stack overflow :-) code-only answers aren't useful for the community. Please look at How to Answer
– JimHawkins
Jul 13 '17 at 10:45
2
2
Welcome to stack overflow :-) code-only answers aren't useful for the community. Please look at How to Answer
– JimHawkins
Jul 13 '17 at 10:45
Welcome to stack overflow :-) code-only answers aren't useful for the community. Please look at How to Answer
– JimHawkins
Jul 13 '17 at 10:45
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f26955263%2fis-there-any-other-waynot-sendkeys-to-enter-text-into-textbox-using-selenium-w%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
3
Why would there be another way? What is the problem with sendKeys? API designers rarely provide 5 methods doing the same thing.
– JB Nizet
Nov 16 '14 at 8:49
One interviewer asked this question...
– Vasantha
Nov 16 '14 at 10:00