Is there any other way(not sendKeys) to enter text into textbox using selenium webdriver?












0















Is there any other way(not sendKeys) to enter text into textbox using selenium webdriver ?










share|improve this question




















  • 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
















0















Is there any other way(not sendKeys) to enter text into textbox using selenium webdriver ?










share|improve this question




















  • 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














0












0








0








Is there any other way(not sendKeys) to enter text into textbox using selenium webdriver ?










share|improve this question
















Is there any other way(not sendKeys) to enter text into textbox using selenium webdriver ?







java selenium-webdriver






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 16 '14 at 10:01









Anirudh

1,33822250




1,33822250










asked Nov 16 '14 at 8:44









VasanthaVasantha

1312311




1312311








  • 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





    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












3 Answers
3






active

oldest

votes


















0














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';);





share|improve this answer
























  • 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



















0














@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'");





share|improve this answer































    0














    WebElement name=driver.findElement(By.name("username"));
    ((JavascriptExecutor)driver).executeAsyncScript("arguments[0].value='admin'",name);





    share|improve this answer





















    • 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











    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
    });


    }
    });














    draft saved

    draft discarded


















    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









    0














    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';);





    share|improve this answer
























    • 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
















    0














    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';);





    share|improve this answer
























    • 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














    0












    0








    0







    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';);





    share|improve this answer













    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';);






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 16 '14 at 9:08









    AnirudhAnirudh

    1,33822250




    1,33822250













    • 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













    • 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













    0














    @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'");





    share|improve this answer




























      0














      @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'");





      share|improve this answer


























        0












        0








        0







        @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'");





        share|improve this answer













        @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'");






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 29 '15 at 11:58









        Virender SinghVirender Singh

        11




        11























            0














            WebElement name=driver.findElement(By.name("username"));
            ((JavascriptExecutor)driver).executeAsyncScript("arguments[0].value='admin'",name);





            share|improve this answer





















            • 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
















            0














            WebElement name=driver.findElement(By.name("username"));
            ((JavascriptExecutor)driver).executeAsyncScript("arguments[0].value='admin'",name);





            share|improve this answer





















            • 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














            0












            0








            0







            WebElement name=driver.findElement(By.name("username"));
            ((JavascriptExecutor)driver).executeAsyncScript("arguments[0].value='admin'",name);





            share|improve this answer















            WebElement name=driver.findElement(By.name("username"));
            ((JavascriptExecutor)driver).executeAsyncScript("arguments[0].value='admin'",name);






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Jul 13 '17 at 7:58









            Bugs

            4,14992537




            4,14992537










            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














            • 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


















            draft saved

            draft discarded




















































            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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            Wiesbaden

            Marschland

            Dieringhausen