How to override sendkeys() method using java










-1















I want to override sendkeys(). It should clear first then enter the key



public Actions SendKeys(string keysToSend)











share|improve this question



















  • 1





    What is the problem? call element.clear()

    – Guy
    Nov 15 '18 at 12:16












  • I am handling a old project , where they have used only sendkeys() without clearing the existing content in all the places. so i want to use some thing like override of method. so that i can save my effort

    – Java_Help_Line
    Nov 15 '18 at 12:34












  • You mean they used webelement.sendKeys() everywhere? or they used some general method like the one you posted?

    – Guy
    Nov 15 '18 at 13:22
















-1















I want to override sendkeys(). It should clear first then enter the key



public Actions SendKeys(string keysToSend)











share|improve this question



















  • 1





    What is the problem? call element.clear()

    – Guy
    Nov 15 '18 at 12:16












  • I am handling a old project , where they have used only sendkeys() without clearing the existing content in all the places. so i want to use some thing like override of method. so that i can save my effort

    – Java_Help_Line
    Nov 15 '18 at 12:34












  • You mean they used webelement.sendKeys() everywhere? or they used some general method like the one you posted?

    – Guy
    Nov 15 '18 at 13:22














-1












-1








-1








I want to override sendkeys(). It should clear first then enter the key



public Actions SendKeys(string keysToSend)











share|improve this question
















I want to override sendkeys(). It should clear first then enter the key



public Actions SendKeys(string keysToSend)








java selenium selenium-webdriver webdriver






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 15 '18 at 14:21









DebanjanB

44.4k124587




44.4k124587










asked Nov 15 '18 at 12:15









Java_Help_LineJava_Help_Line

342




342







  • 1





    What is the problem? call element.clear()

    – Guy
    Nov 15 '18 at 12:16












  • I am handling a old project , where they have used only sendkeys() without clearing the existing content in all the places. so i want to use some thing like override of method. so that i can save my effort

    – Java_Help_Line
    Nov 15 '18 at 12:34












  • You mean they used webelement.sendKeys() everywhere? or they used some general method like the one you posted?

    – Guy
    Nov 15 '18 at 13:22













  • 1





    What is the problem? call element.clear()

    – Guy
    Nov 15 '18 at 12:16












  • I am handling a old project , where they have used only sendkeys() without clearing the existing content in all the places. so i want to use some thing like override of method. so that i can save my effort

    – Java_Help_Line
    Nov 15 '18 at 12:34












  • You mean they used webelement.sendKeys() everywhere? or they used some general method like the one you posted?

    – Guy
    Nov 15 '18 at 13:22








1




1





What is the problem? call element.clear()

– Guy
Nov 15 '18 at 12:16






What is the problem? call element.clear()

– Guy
Nov 15 '18 at 12:16














I am handling a old project , where they have used only sendkeys() without clearing the existing content in all the places. so i want to use some thing like override of method. so that i can save my effort

– Java_Help_Line
Nov 15 '18 at 12:34






I am handling a old project , where they have used only sendkeys() without clearing the existing content in all the places. so i want to use some thing like override of method. so that i can save my effort

– Java_Help_Line
Nov 15 '18 at 12:34














You mean they used webelement.sendKeys() everywhere? or they used some general method like the one you posted?

– Guy
Nov 15 '18 at 13:22






You mean they used webelement.sendKeys() everywhere? or they used some general method like the one you posted?

– Guy
Nov 15 '18 at 13:22













1 Answer
1






active

oldest

votes


















0














As per the documentation the sendKeys() method is defined as:



void sendKeys(java.lang.CharSequence... keysToSend)

Parameters:
keysToSend - character sequence to send to the element
Throws:
java.lang.IllegalArgumentException - if keysToSend is null


So, its clear that we can't override SendKeys() method in the first place.



Alternative



As an alternative, referring to the discussion A general question about Java and WebDriver @KrishnanMahadevan mentions that you can make an attempt to override sendKeys() method following the below mentioned concepts, steps and procedure:



  • The concept may vary depending on what WebDriver variant you are working with.

  • As all of the WebDriver implementations extend RemoteWebDriver and you are only going to work with RemoteWebDriver, so while working with Selenium Grid you can use the following tweak.

  • If you are not working with RemoteWebDriver but instead working with GeckoDriver, ChromeDriver, IEDriverServer, then you would need to extend the respective classes, override all of the findElement(), findElements(), etc methods in these classes to return an instance of my_web_element.


  • my_web_element would basically be your class wherein you would extend RemoteWebElement and then override
    org.openqa.selenium.remote.RemoteWebElement.sendKeys(CharSequence...)

The above step will definitely get you started.






share|improve this answer
























    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%2f53319309%2fhow-to-override-sendkeys-method-using-java%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    As per the documentation the sendKeys() method is defined as:



    void sendKeys(java.lang.CharSequence... keysToSend)

    Parameters:
    keysToSend - character sequence to send to the element
    Throws:
    java.lang.IllegalArgumentException - if keysToSend is null


    So, its clear that we can't override SendKeys() method in the first place.



    Alternative



    As an alternative, referring to the discussion A general question about Java and WebDriver @KrishnanMahadevan mentions that you can make an attempt to override sendKeys() method following the below mentioned concepts, steps and procedure:



    • The concept may vary depending on what WebDriver variant you are working with.

    • As all of the WebDriver implementations extend RemoteWebDriver and you are only going to work with RemoteWebDriver, so while working with Selenium Grid you can use the following tweak.

    • If you are not working with RemoteWebDriver but instead working with GeckoDriver, ChromeDriver, IEDriverServer, then you would need to extend the respective classes, override all of the findElement(), findElements(), etc methods in these classes to return an instance of my_web_element.


    • my_web_element would basically be your class wherein you would extend RemoteWebElement and then override
      org.openqa.selenium.remote.RemoteWebElement.sendKeys(CharSequence...)

    The above step will definitely get you started.






    share|improve this answer





























      0














      As per the documentation the sendKeys() method is defined as:



      void sendKeys(java.lang.CharSequence... keysToSend)

      Parameters:
      keysToSend - character sequence to send to the element
      Throws:
      java.lang.IllegalArgumentException - if keysToSend is null


      So, its clear that we can't override SendKeys() method in the first place.



      Alternative



      As an alternative, referring to the discussion A general question about Java and WebDriver @KrishnanMahadevan mentions that you can make an attempt to override sendKeys() method following the below mentioned concepts, steps and procedure:



      • The concept may vary depending on what WebDriver variant you are working with.

      • As all of the WebDriver implementations extend RemoteWebDriver and you are only going to work with RemoteWebDriver, so while working with Selenium Grid you can use the following tweak.

      • If you are not working with RemoteWebDriver but instead working with GeckoDriver, ChromeDriver, IEDriverServer, then you would need to extend the respective classes, override all of the findElement(), findElements(), etc methods in these classes to return an instance of my_web_element.


      • my_web_element would basically be your class wherein you would extend RemoteWebElement and then override
        org.openqa.selenium.remote.RemoteWebElement.sendKeys(CharSequence...)

      The above step will definitely get you started.






      share|improve this answer



























        0












        0








        0







        As per the documentation the sendKeys() method is defined as:



        void sendKeys(java.lang.CharSequence... keysToSend)

        Parameters:
        keysToSend - character sequence to send to the element
        Throws:
        java.lang.IllegalArgumentException - if keysToSend is null


        So, its clear that we can't override SendKeys() method in the first place.



        Alternative



        As an alternative, referring to the discussion A general question about Java and WebDriver @KrishnanMahadevan mentions that you can make an attempt to override sendKeys() method following the below mentioned concepts, steps and procedure:



        • The concept may vary depending on what WebDriver variant you are working with.

        • As all of the WebDriver implementations extend RemoteWebDriver and you are only going to work with RemoteWebDriver, so while working with Selenium Grid you can use the following tweak.

        • If you are not working with RemoteWebDriver but instead working with GeckoDriver, ChromeDriver, IEDriverServer, then you would need to extend the respective classes, override all of the findElement(), findElements(), etc methods in these classes to return an instance of my_web_element.


        • my_web_element would basically be your class wherein you would extend RemoteWebElement and then override
          org.openqa.selenium.remote.RemoteWebElement.sendKeys(CharSequence...)

        The above step will definitely get you started.






        share|improve this answer















        As per the documentation the sendKeys() method is defined as:



        void sendKeys(java.lang.CharSequence... keysToSend)

        Parameters:
        keysToSend - character sequence to send to the element
        Throws:
        java.lang.IllegalArgumentException - if keysToSend is null


        So, its clear that we can't override SendKeys() method in the first place.



        Alternative



        As an alternative, referring to the discussion A general question about Java and WebDriver @KrishnanMahadevan mentions that you can make an attempt to override sendKeys() method following the below mentioned concepts, steps and procedure:



        • The concept may vary depending on what WebDriver variant you are working with.

        • As all of the WebDriver implementations extend RemoteWebDriver and you are only going to work with RemoteWebDriver, so while working with Selenium Grid you can use the following tweak.

        • If you are not working with RemoteWebDriver but instead working with GeckoDriver, ChromeDriver, IEDriverServer, then you would need to extend the respective classes, override all of the findElement(), findElements(), etc methods in these classes to return an instance of my_web_element.


        • my_web_element would basically be your class wherein you would extend RemoteWebElement and then override
          org.openqa.selenium.remote.RemoteWebElement.sendKeys(CharSequence...)

        The above step will definitely get you started.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 15 '18 at 14:46

























        answered Nov 15 '18 at 14:28









        DebanjanBDebanjanB

        44.4k124587




        44.4k124587





























            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%2f53319309%2fhow-to-override-sendkeys-method-using-java%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







            這個網誌中的熱門文章

            What does pagestruct do in Eviews?

            Dutch intervention in Lombok and Karangasem

            Channel Islands