Selenium driver.findElement finds element, sendKeys works, then nulls out when moving to a new field
Using Selenium I am successfully finding element and adding info using sendKeys. However, when it moves to the next driver.findElement field it nulls out the previous field. I have many fields that I am searching for and filling out but not understanding why it is nulling out the fields when it moves on.
Code example (finds field, types Jane Does but nulls it out when moving to the Email Address question):
//Users Supervisor's Full Name question
WebElement element4 = driver.findElement(By.id("QS005056A70C8EWNe8UAZYOxDAVk0C"));
element4.sendKeys("Jane Doe");
//Users Supervisor's Email Address question
WebElement element5 = driver.findElement(By.id("QS005056A70C8EdNe8UAPfKxDAelUC"));
element5.sendKeys("jane.doe@gmail.com");
sendkeys
add a comment |
Using Selenium I am successfully finding element and adding info using sendKeys. However, when it moves to the next driver.findElement field it nulls out the previous field. I have many fields that I am searching for and filling out but not understanding why it is nulling out the fields when it moves on.
Code example (finds field, types Jane Does but nulls it out when moving to the Email Address question):
//Users Supervisor's Full Name question
WebElement element4 = driver.findElement(By.id("QS005056A70C8EWNe8UAZYOxDAVk0C"));
element4.sendKeys("Jane Doe");
//Users Supervisor's Email Address question
WebElement element5 = driver.findElement(By.id("QS005056A70C8EdNe8UAPfKxDAelUC"));
element5.sendKeys("jane.doe@gmail.com");
sendkeys
add a comment |
Using Selenium I am successfully finding element and adding info using sendKeys. However, when it moves to the next driver.findElement field it nulls out the previous field. I have many fields that I am searching for and filling out but not understanding why it is nulling out the fields when it moves on.
Code example (finds field, types Jane Does but nulls it out when moving to the Email Address question):
//Users Supervisor's Full Name question
WebElement element4 = driver.findElement(By.id("QS005056A70C8EWNe8UAZYOxDAVk0C"));
element4.sendKeys("Jane Doe");
//Users Supervisor's Email Address question
WebElement element5 = driver.findElement(By.id("QS005056A70C8EdNe8UAPfKxDAelUC"));
element5.sendKeys("jane.doe@gmail.com");
sendkeys
Using Selenium I am successfully finding element and adding info using sendKeys. However, when it moves to the next driver.findElement field it nulls out the previous field. I have many fields that I am searching for and filling out but not understanding why it is nulling out the fields when it moves on.
Code example (finds field, types Jane Does but nulls it out when moving to the Email Address question):
//Users Supervisor's Full Name question
WebElement element4 = driver.findElement(By.id("QS005056A70C8EWNe8UAZYOxDAVk0C"));
element4.sendKeys("Jane Doe");
//Users Supervisor's Email Address question
WebElement element5 = driver.findElement(By.id("QS005056A70C8EdNe8UAPfKxDAelUC"));
element5.sendKeys("jane.doe@gmail.com");
sendkeys
sendkeys
asked Nov 14 '18 at 21:08
TerriTerri
64
64
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
What happens when you try the actions manually, does the same problem occur?
Does the id of the element change after using sendKeys?
When I try the actions manually the fields set correctly and are not nulled out. The element id stays the same after using sendKeys. It is when it moves to the next element and does the sendKeys on that one that the first one is nulled. These fields build off of each other when you set it manually. ( EX: 2nd can't be set till first is set, 3rd can't be set till 2nd is set, etc.)
– Terri
Nov 15 '18 at 13:28
What is the result if you dogetAttribute("value")
orgetText()
String elementValueOne = driver.findElement(By.id("QS005056A70C8EWNe8UAZYOxDAVk0C")).getAttribute("value"); String elementValueTwo = driver.findElement(By.id("QS005056A70C8EWNe8UAZYOxDAVk0C")).getText();
– user2908623
Nov 15 '18 at 13:44
I tried getAttribute and it does nothing. No errors, but it doesn't set the field.
– Terri
Nov 15 '18 at 15:28
Could you try to use getAttribute and getText after you set it with sendKeys?
– user2908623
Nov 16 '18 at 7:36
I'm gonna close this question out as I think I'm going the wrong direction with the test. I'm trying to set the fields using sendKeys when the true test is to actually click the menu and select the options so I'm redoing my code. Will create a new question if I run into problems. Thank you user2908623 for your help.
– Terri
Nov 20 '18 at 14:35
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%2f53308742%2fselenium-driver-findelement-finds-element-sendkeys-works-then-nulls-out-when-m%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
What happens when you try the actions manually, does the same problem occur?
Does the id of the element change after using sendKeys?
When I try the actions manually the fields set correctly and are not nulled out. The element id stays the same after using sendKeys. It is when it moves to the next element and does the sendKeys on that one that the first one is nulled. These fields build off of each other when you set it manually. ( EX: 2nd can't be set till first is set, 3rd can't be set till 2nd is set, etc.)
– Terri
Nov 15 '18 at 13:28
What is the result if you dogetAttribute("value")
orgetText()
String elementValueOne = driver.findElement(By.id("QS005056A70C8EWNe8UAZYOxDAVk0C")).getAttribute("value"); String elementValueTwo = driver.findElement(By.id("QS005056A70C8EWNe8UAZYOxDAVk0C")).getText();
– user2908623
Nov 15 '18 at 13:44
I tried getAttribute and it does nothing. No errors, but it doesn't set the field.
– Terri
Nov 15 '18 at 15:28
Could you try to use getAttribute and getText after you set it with sendKeys?
– user2908623
Nov 16 '18 at 7:36
I'm gonna close this question out as I think I'm going the wrong direction with the test. I'm trying to set the fields using sendKeys when the true test is to actually click the menu and select the options so I'm redoing my code. Will create a new question if I run into problems. Thank you user2908623 for your help.
– Terri
Nov 20 '18 at 14:35
add a comment |
What happens when you try the actions manually, does the same problem occur?
Does the id of the element change after using sendKeys?
When I try the actions manually the fields set correctly and are not nulled out. The element id stays the same after using sendKeys. It is when it moves to the next element and does the sendKeys on that one that the first one is nulled. These fields build off of each other when you set it manually. ( EX: 2nd can't be set till first is set, 3rd can't be set till 2nd is set, etc.)
– Terri
Nov 15 '18 at 13:28
What is the result if you dogetAttribute("value")
orgetText()
String elementValueOne = driver.findElement(By.id("QS005056A70C8EWNe8UAZYOxDAVk0C")).getAttribute("value"); String elementValueTwo = driver.findElement(By.id("QS005056A70C8EWNe8UAZYOxDAVk0C")).getText();
– user2908623
Nov 15 '18 at 13:44
I tried getAttribute and it does nothing. No errors, but it doesn't set the field.
– Terri
Nov 15 '18 at 15:28
Could you try to use getAttribute and getText after you set it with sendKeys?
– user2908623
Nov 16 '18 at 7:36
I'm gonna close this question out as I think I'm going the wrong direction with the test. I'm trying to set the fields using sendKeys when the true test is to actually click the menu and select the options so I'm redoing my code. Will create a new question if I run into problems. Thank you user2908623 for your help.
– Terri
Nov 20 '18 at 14:35
add a comment |
What happens when you try the actions manually, does the same problem occur?
Does the id of the element change after using sendKeys?
What happens when you try the actions manually, does the same problem occur?
Does the id of the element change after using sendKeys?
answered Nov 14 '18 at 21:44
user2908623user2908623
476
476
When I try the actions manually the fields set correctly and are not nulled out. The element id stays the same after using sendKeys. It is when it moves to the next element and does the sendKeys on that one that the first one is nulled. These fields build off of each other when you set it manually. ( EX: 2nd can't be set till first is set, 3rd can't be set till 2nd is set, etc.)
– Terri
Nov 15 '18 at 13:28
What is the result if you dogetAttribute("value")
orgetText()
String elementValueOne = driver.findElement(By.id("QS005056A70C8EWNe8UAZYOxDAVk0C")).getAttribute("value"); String elementValueTwo = driver.findElement(By.id("QS005056A70C8EWNe8UAZYOxDAVk0C")).getText();
– user2908623
Nov 15 '18 at 13:44
I tried getAttribute and it does nothing. No errors, but it doesn't set the field.
– Terri
Nov 15 '18 at 15:28
Could you try to use getAttribute and getText after you set it with sendKeys?
– user2908623
Nov 16 '18 at 7:36
I'm gonna close this question out as I think I'm going the wrong direction with the test. I'm trying to set the fields using sendKeys when the true test is to actually click the menu and select the options so I'm redoing my code. Will create a new question if I run into problems. Thank you user2908623 for your help.
– Terri
Nov 20 '18 at 14:35
add a comment |
When I try the actions manually the fields set correctly and are not nulled out. The element id stays the same after using sendKeys. It is when it moves to the next element and does the sendKeys on that one that the first one is nulled. These fields build off of each other when you set it manually. ( EX: 2nd can't be set till first is set, 3rd can't be set till 2nd is set, etc.)
– Terri
Nov 15 '18 at 13:28
What is the result if you dogetAttribute("value")
orgetText()
String elementValueOne = driver.findElement(By.id("QS005056A70C8EWNe8UAZYOxDAVk0C")).getAttribute("value"); String elementValueTwo = driver.findElement(By.id("QS005056A70C8EWNe8UAZYOxDAVk0C")).getText();
– user2908623
Nov 15 '18 at 13:44
I tried getAttribute and it does nothing. No errors, but it doesn't set the field.
– Terri
Nov 15 '18 at 15:28
Could you try to use getAttribute and getText after you set it with sendKeys?
– user2908623
Nov 16 '18 at 7:36
I'm gonna close this question out as I think I'm going the wrong direction with the test. I'm trying to set the fields using sendKeys when the true test is to actually click the menu and select the options so I'm redoing my code. Will create a new question if I run into problems. Thank you user2908623 for your help.
– Terri
Nov 20 '18 at 14:35
When I try the actions manually the fields set correctly and are not nulled out. The element id stays the same after using sendKeys. It is when it moves to the next element and does the sendKeys on that one that the first one is nulled. These fields build off of each other when you set it manually. ( EX: 2nd can't be set till first is set, 3rd can't be set till 2nd is set, etc.)
– Terri
Nov 15 '18 at 13:28
When I try the actions manually the fields set correctly and are not nulled out. The element id stays the same after using sendKeys. It is when it moves to the next element and does the sendKeys on that one that the first one is nulled. These fields build off of each other when you set it manually. ( EX: 2nd can't be set till first is set, 3rd can't be set till 2nd is set, etc.)
– Terri
Nov 15 '18 at 13:28
What is the result if you do
getAttribute("value")
or getText()
String elementValueOne = driver.findElement(By.id("QS005056A70C8EWNe8UAZYOxDAVk0C")).getAttribute("value"); String elementValueTwo = driver.findElement(By.id("QS005056A70C8EWNe8UAZYOxDAVk0C")).getText();
– user2908623
Nov 15 '18 at 13:44
What is the result if you do
getAttribute("value")
or getText()
String elementValueOne = driver.findElement(By.id("QS005056A70C8EWNe8UAZYOxDAVk0C")).getAttribute("value"); String elementValueTwo = driver.findElement(By.id("QS005056A70C8EWNe8UAZYOxDAVk0C")).getText();
– user2908623
Nov 15 '18 at 13:44
I tried getAttribute and it does nothing. No errors, but it doesn't set the field.
– Terri
Nov 15 '18 at 15:28
I tried getAttribute and it does nothing. No errors, but it doesn't set the field.
– Terri
Nov 15 '18 at 15:28
Could you try to use getAttribute and getText after you set it with sendKeys?
– user2908623
Nov 16 '18 at 7:36
Could you try to use getAttribute and getText after you set it with sendKeys?
– user2908623
Nov 16 '18 at 7:36
I'm gonna close this question out as I think I'm going the wrong direction with the test. I'm trying to set the fields using sendKeys when the true test is to actually click the menu and select the options so I'm redoing my code. Will create a new question if I run into problems. Thank you user2908623 for your help.
– Terri
Nov 20 '18 at 14:35
I'm gonna close this question out as I think I'm going the wrong direction with the test. I'm trying to set the fields using sendKeys when the true test is to actually click the menu and select the options so I'm redoing my code. Will create a new question if I run into problems. Thank you user2908623 for your help.
– Terri
Nov 20 '18 at 14:35
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%2f53308742%2fselenium-driver-findelement-finds-element-sendkeys-works-then-nulls-out-when-m%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