How to override sendkeys() method using java
I want to override sendkeys(). It should clear first then enter the key
public Actions SendKeys(string keysToSend)
java selenium selenium-webdriver webdriver
add a comment |
I want to override sendkeys(). It should clear first then enter the key
public Actions SendKeys(string keysToSend)
java selenium selenium-webdriver webdriver
1
What is the problem? callelement.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 usedwebelement.sendKeys()everywhere? or they used some general method like the one you posted?
– Guy
Nov 15 '18 at 13:22
add a comment |
I want to override sendkeys(). It should clear first then enter the key
public Actions SendKeys(string keysToSend)
java selenium selenium-webdriver webdriver
I want to override sendkeys(). It should clear first then enter the key
public Actions SendKeys(string keysToSend)
java selenium selenium-webdriver webdriver
java selenium selenium-webdriver webdriver
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? callelement.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 usedwebelement.sendKeys()everywhere? or they used some general method like the one you posted?
– Guy
Nov 15 '18 at 13:22
add a comment |
1
What is the problem? callelement.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 usedwebelement.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
add a comment |
1 Answer
1
active
oldest
votes
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
extendthe respective classes,overrideall of thefindElement(),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 overrideorg.openqa.selenium.remote.RemoteWebElement.sendKeys(CharSequence...)
The above step will definitely get you started.
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%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
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
extendthe respective classes,overrideall of thefindElement(),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 overrideorg.openqa.selenium.remote.RemoteWebElement.sendKeys(CharSequence...)
The above step will definitely get you started.
add a comment |
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
extendthe respective classes,overrideall of thefindElement(),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 overrideorg.openqa.selenium.remote.RemoteWebElement.sendKeys(CharSequence...)
The above step will definitely get you started.
add a comment |
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
extendthe respective classes,overrideall of thefindElement(),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 overrideorg.openqa.selenium.remote.RemoteWebElement.sendKeys(CharSequence...)
The above step will definitely get you started.
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
extendthe respective classes,overrideall of thefindElement(),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 overrideorg.openqa.selenium.remote.RemoteWebElement.sendKeys(CharSequence...)
The above step will definitely get you started.
edited Nov 15 '18 at 14:46
answered Nov 15 '18 at 14:28
DebanjanBDebanjanB
44.4k124587
44.4k124587
add a comment |
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%2f53319309%2fhow-to-override-sendkeys-method-using-java%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
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