Clearing Text value by Javascript Executor and Actions are NOT working!- Selenium
up vote
0
down vote
favorite
Im trying to clear the Existing value of a field[TextBox]by the folowing ways,
- Action - MoveToElement - Keys.Backspace
- Selenium method - Clear()
everytime: used to get the same error message :No such elementexception though the element identification is correct and even i tried to focus the element before performing the action but still failed.
suggest me the approach please
note: Microsoft.Dynamics CRM application
c# selenium-webdriver dynamics-crm
|
show 5 more comments
up vote
0
down vote
favorite
Im trying to clear the Existing value of a field[TextBox]by the folowing ways,
- Action - MoveToElement - Keys.Backspace
- Selenium method - Clear()
everytime: used to get the same error message :No such elementexception though the element identification is correct and even i tried to focus the element before performing the action but still failed.
suggest me the approach please
note: Microsoft.Dynamics CRM application
c# selenium-webdriver dynamics-crm
please post a snippet of your HTML including the element which you are trying to clear. Is the element contained within a frame or iframe?
– Ryan Wilson
Nov 21 at 19:50
No such element == you have wrong locator.
– Vladimir Efimov
Nov 21 at 19:50
1
@VladimirEfimov It's possible the locator is correct but the element is inside a frame, iframe document. If it's inside a frame or iframe, the driver needs to be moved to the frame document for it to be able to find the element.
– Ryan Wilson
Nov 21 at 19:51
@RyanWilson yep, good addition makes sense... but anyway stan says that he was able to "focus" an element whetever that means... probably 'focus' it via browser inspector.
– Vladimir Efimov
Nov 21 at 19:52
1
when i enter the value for the first time - selenium ables to identify the element BUT when i access the same element for clearing the value - selenium fails to locate it and throws the error! @RyanWilson
– stan
Nov 21 at 20:36
|
show 5 more comments
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Im trying to clear the Existing value of a field[TextBox]by the folowing ways,
- Action - MoveToElement - Keys.Backspace
- Selenium method - Clear()
everytime: used to get the same error message :No such elementexception though the element identification is correct and even i tried to focus the element before performing the action but still failed.
suggest me the approach please
note: Microsoft.Dynamics CRM application
c# selenium-webdriver dynamics-crm
Im trying to clear the Existing value of a field[TextBox]by the folowing ways,
- Action - MoveToElement - Keys.Backspace
- Selenium method - Clear()
everytime: used to get the same error message :No such elementexception though the element identification is correct and even i tried to focus the element before performing the action but still failed.
suggest me the approach please
note: Microsoft.Dynamics CRM application
c# selenium-webdriver dynamics-crm
c# selenium-webdriver dynamics-crm
asked Nov 21 at 19:48
stan
206
206
please post a snippet of your HTML including the element which you are trying to clear. Is the element contained within a frame or iframe?
– Ryan Wilson
Nov 21 at 19:50
No such element == you have wrong locator.
– Vladimir Efimov
Nov 21 at 19:50
1
@VladimirEfimov It's possible the locator is correct but the element is inside a frame, iframe document. If it's inside a frame or iframe, the driver needs to be moved to the frame document for it to be able to find the element.
– Ryan Wilson
Nov 21 at 19:51
@RyanWilson yep, good addition makes sense... but anyway stan says that he was able to "focus" an element whetever that means... probably 'focus' it via browser inspector.
– Vladimir Efimov
Nov 21 at 19:52
1
when i enter the value for the first time - selenium ables to identify the element BUT when i access the same element for clearing the value - selenium fails to locate it and throws the error! @RyanWilson
– stan
Nov 21 at 20:36
|
show 5 more comments
please post a snippet of your HTML including the element which you are trying to clear. Is the element contained within a frame or iframe?
– Ryan Wilson
Nov 21 at 19:50
No such element == you have wrong locator.
– Vladimir Efimov
Nov 21 at 19:50
1
@VladimirEfimov It's possible the locator is correct but the element is inside a frame, iframe document. If it's inside a frame or iframe, the driver needs to be moved to the frame document for it to be able to find the element.
– Ryan Wilson
Nov 21 at 19:51
@RyanWilson yep, good addition makes sense... but anyway stan says that he was able to "focus" an element whetever that means... probably 'focus' it via browser inspector.
– Vladimir Efimov
Nov 21 at 19:52
1
when i enter the value for the first time - selenium ables to identify the element BUT when i access the same element for clearing the value - selenium fails to locate it and throws the error! @RyanWilson
– stan
Nov 21 at 20:36
please post a snippet of your HTML including the element which you are trying to clear. Is the element contained within a frame or iframe?
– Ryan Wilson
Nov 21 at 19:50
please post a snippet of your HTML including the element which you are trying to clear. Is the element contained within a frame or iframe?
– Ryan Wilson
Nov 21 at 19:50
No such element == you have wrong locator.
– Vladimir Efimov
Nov 21 at 19:50
No such element == you have wrong locator.
– Vladimir Efimov
Nov 21 at 19:50
1
1
@VladimirEfimov It's possible the locator is correct but the element is inside a frame, iframe document. If it's inside a frame or iframe, the driver needs to be moved to the frame document for it to be able to find the element.
– Ryan Wilson
Nov 21 at 19:51
@VladimirEfimov It's possible the locator is correct but the element is inside a frame, iframe document. If it's inside a frame or iframe, the driver needs to be moved to the frame document for it to be able to find the element.
– Ryan Wilson
Nov 21 at 19:51
@RyanWilson yep, good addition makes sense... but anyway stan says that he was able to "focus" an element whetever that means... probably 'focus' it via browser inspector.
– Vladimir Efimov
Nov 21 at 19:52
@RyanWilson yep, good addition makes sense... but anyway stan says that he was able to "focus" an element whetever that means... probably 'focus' it via browser inspector.
– Vladimir Efimov
Nov 21 at 19:52
1
1
when i enter the value for the first time - selenium ables to identify the element BUT when i access the same element for clearing the value - selenium fails to locate it and throws the error! @RyanWilson
– stan
Nov 21 at 20:36
when i enter the value for the first time - selenium ables to identify the element BUT when i access the same element for clearing the value - selenium fails to locate it and throws the error! @RyanWilson
– stan
Nov 21 at 20:36
|
show 5 more comments
1 Answer
1
active
oldest
votes
up vote
1
down vote
Based on additional data from comments here is what probably happens:
- You get an instance of
WebElement
- there is an element matching yourlocator
at that moment of time
- You enter some value to the element - this action most likely changes your web element somehow (e.g. changes style/class/or even a tag)
- You trying to get an instance of the same
WebElement
using the samelocator
and NoSuchElementException is thrown - this is because the element is now not exactly the same as in step 1
If you add sample HTML before entering text and after the text is entered we probably will be able to provide the exact solution.
As of now I can suggest 2 ways:
- When you want to clear the text - you need to use different locator. That will match exactly the element you need to work with.
- If your page does not reload after you type text, you just can create a variable for
WebElement
, find element and store it to the variable before entering the text, then work with this variable enter a text usingsendKeys
, then clear text applyingclear
method to this same variable. I.e. it might be that you don't really need to callfindElement
twice if the page stays the same.
1
problem is focus is not on the element. driver was referring another page after switching to the current page i was able get the handle of webelement.
– stan
Nov 24 at 19:27
many thanks for providing nice explanation and suggestions
– stan
Nov 24 at 19:28
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
Based on additional data from comments here is what probably happens:
- You get an instance of
WebElement
- there is an element matching yourlocator
at that moment of time
- You enter some value to the element - this action most likely changes your web element somehow (e.g. changes style/class/or even a tag)
- You trying to get an instance of the same
WebElement
using the samelocator
and NoSuchElementException is thrown - this is because the element is now not exactly the same as in step 1
If you add sample HTML before entering text and after the text is entered we probably will be able to provide the exact solution.
As of now I can suggest 2 ways:
- When you want to clear the text - you need to use different locator. That will match exactly the element you need to work with.
- If your page does not reload after you type text, you just can create a variable for
WebElement
, find element and store it to the variable before entering the text, then work with this variable enter a text usingsendKeys
, then clear text applyingclear
method to this same variable. I.e. it might be that you don't really need to callfindElement
twice if the page stays the same.
1
problem is focus is not on the element. driver was referring another page after switching to the current page i was able get the handle of webelement.
– stan
Nov 24 at 19:27
many thanks for providing nice explanation and suggestions
– stan
Nov 24 at 19:28
add a comment |
up vote
1
down vote
Based on additional data from comments here is what probably happens:
- You get an instance of
WebElement
- there is an element matching yourlocator
at that moment of time
- You enter some value to the element - this action most likely changes your web element somehow (e.g. changes style/class/or even a tag)
- You trying to get an instance of the same
WebElement
using the samelocator
and NoSuchElementException is thrown - this is because the element is now not exactly the same as in step 1
If you add sample HTML before entering text and after the text is entered we probably will be able to provide the exact solution.
As of now I can suggest 2 ways:
- When you want to clear the text - you need to use different locator. That will match exactly the element you need to work with.
- If your page does not reload after you type text, you just can create a variable for
WebElement
, find element and store it to the variable before entering the text, then work with this variable enter a text usingsendKeys
, then clear text applyingclear
method to this same variable. I.e. it might be that you don't really need to callfindElement
twice if the page stays the same.
1
problem is focus is not on the element. driver was referring another page after switching to the current page i was able get the handle of webelement.
– stan
Nov 24 at 19:27
many thanks for providing nice explanation and suggestions
– stan
Nov 24 at 19:28
add a comment |
up vote
1
down vote
up vote
1
down vote
Based on additional data from comments here is what probably happens:
- You get an instance of
WebElement
- there is an element matching yourlocator
at that moment of time
- You enter some value to the element - this action most likely changes your web element somehow (e.g. changes style/class/or even a tag)
- You trying to get an instance of the same
WebElement
using the samelocator
and NoSuchElementException is thrown - this is because the element is now not exactly the same as in step 1
If you add sample HTML before entering text and after the text is entered we probably will be able to provide the exact solution.
As of now I can suggest 2 ways:
- When you want to clear the text - you need to use different locator. That will match exactly the element you need to work with.
- If your page does not reload after you type text, you just can create a variable for
WebElement
, find element and store it to the variable before entering the text, then work with this variable enter a text usingsendKeys
, then clear text applyingclear
method to this same variable. I.e. it might be that you don't really need to callfindElement
twice if the page stays the same.
Based on additional data from comments here is what probably happens:
- You get an instance of
WebElement
- there is an element matching yourlocator
at that moment of time
- You enter some value to the element - this action most likely changes your web element somehow (e.g. changes style/class/or even a tag)
- You trying to get an instance of the same
WebElement
using the samelocator
and NoSuchElementException is thrown - this is because the element is now not exactly the same as in step 1
If you add sample HTML before entering text and after the text is entered we probably will be able to provide the exact solution.
As of now I can suggest 2 ways:
- When you want to clear the text - you need to use different locator. That will match exactly the element you need to work with.
- If your page does not reload after you type text, you just can create a variable for
WebElement
, find element and store it to the variable before entering the text, then work with this variable enter a text usingsendKeys
, then clear text applyingclear
method to this same variable. I.e. it might be that you don't really need to callfindElement
twice if the page stays the same.
answered Nov 22 at 5:53
Vladimir Efimov
655311
655311
1
problem is focus is not on the element. driver was referring another page after switching to the current page i was able get the handle of webelement.
– stan
Nov 24 at 19:27
many thanks for providing nice explanation and suggestions
– stan
Nov 24 at 19:28
add a comment |
1
problem is focus is not on the element. driver was referring another page after switching to the current page i was able get the handle of webelement.
– stan
Nov 24 at 19:27
many thanks for providing nice explanation and suggestions
– stan
Nov 24 at 19:28
1
1
problem is focus is not on the element. driver was referring another page after switching to the current page i was able get the handle of webelement.
– stan
Nov 24 at 19:27
problem is focus is not on the element. driver was referring another page after switching to the current page i was able get the handle of webelement.
– stan
Nov 24 at 19:27
many thanks for providing nice explanation and suggestions
– stan
Nov 24 at 19:28
many thanks for providing nice explanation and suggestions
– stan
Nov 24 at 19:28
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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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%2f53419528%2fclearing-text-value-by-javascript-executor-and-actions-are-not-working-seleniu%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
please post a snippet of your HTML including the element which you are trying to clear. Is the element contained within a frame or iframe?
– Ryan Wilson
Nov 21 at 19:50
No such element == you have wrong locator.
– Vladimir Efimov
Nov 21 at 19:50
1
@VladimirEfimov It's possible the locator is correct but the element is inside a frame, iframe document. If it's inside a frame or iframe, the driver needs to be moved to the frame document for it to be able to find the element.
– Ryan Wilson
Nov 21 at 19:51
@RyanWilson yep, good addition makes sense... but anyway stan says that he was able to "focus" an element whetever that means... probably 'focus' it via browser inspector.
– Vladimir Efimov
Nov 21 at 19:52
1
when i enter the value for the first time - selenium ables to identify the element BUT when i access the same element for clearing the value - selenium fails to locate it and throws the error! @RyanWilson
– stan
Nov 21 at 20:36