Cant fix the StaleElementRefereceException @my send_keys [duplicate]
This question already has an answer here:
Stale element exception python
2 answers
Selenium clicks one time, but next click returns StaleElementReferenceException
1 answer
Message: stale element reference: element is not attached to the page document in Python
1 answer
So I'm pretty new in Python and I tried something for my own, using selenium and firefox. But I got a StaleElementRefereceException when I want to type into a text field in firefox with selenium using send_key()
I tried a lot of Solutions like How to avoid "StaleElementReferenceException" in Selenium? but doesn't help me much because mine is not a click()
, it's a send_key
.
hshtg = "xyz"
driver = self.driver
driver.get(".......")
#time.sleep(3)
cmmnt_elem = driver.find_element_by_xpath('//textarea[@aria-label="Kommentar hinzufügen ..."]')
cmmnt_elem.click()
#time.sleep(3)
cmmnt_elem.send_keys(hshtg)
#time.sleep(3)
cmmnt_elem.send_keys(Keys.RETURN)
But, I got those errors.
File ".....py", line 45, in comment_photo
cmmnt_elem.send_keys(hshtg)
......
selenium.common.exceptions.StaleElementReferenceException: Message: The element
reference of <textarea class="Ypffh"> is stale; either the element is no longer
attached to the DOM, it is not in the current frame context, or the document
has been refreshed
tried this too: (cause of this: How to avoid "StaleElementReferenceException" in Selenium?)
attempts = 0
while attempts < 20:
try:
cmmnt_elem.send_keys(hshtg)
break
except Exception as e:
attempts+1
In case it's helpful, this is the field:comment field on instagram
python selenium browser
marked as duplicate by DebanjanB
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Jan 3 at 12:26
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
Stale element exception python
2 answers
Selenium clicks one time, but next click returns StaleElementReferenceException
1 answer
Message: stale element reference: element is not attached to the page document in Python
1 answer
So I'm pretty new in Python and I tried something for my own, using selenium and firefox. But I got a StaleElementRefereceException when I want to type into a text field in firefox with selenium using send_key()
I tried a lot of Solutions like How to avoid "StaleElementReferenceException" in Selenium? but doesn't help me much because mine is not a click()
, it's a send_key
.
hshtg = "xyz"
driver = self.driver
driver.get(".......")
#time.sleep(3)
cmmnt_elem = driver.find_element_by_xpath('//textarea[@aria-label="Kommentar hinzufügen ..."]')
cmmnt_elem.click()
#time.sleep(3)
cmmnt_elem.send_keys(hshtg)
#time.sleep(3)
cmmnt_elem.send_keys(Keys.RETURN)
But, I got those errors.
File ".....py", line 45, in comment_photo
cmmnt_elem.send_keys(hshtg)
......
selenium.common.exceptions.StaleElementReferenceException: Message: The element
reference of <textarea class="Ypffh"> is stale; either the element is no longer
attached to the DOM, it is not in the current frame context, or the document
has been refreshed
tried this too: (cause of this: How to avoid "StaleElementReferenceException" in Selenium?)
attempts = 0
while attempts < 20:
try:
cmmnt_elem.send_keys(hshtg)
break
except Exception as e:
attempts+1
In case it's helpful, this is the field:comment field on instagram
python selenium browser
marked as duplicate by DebanjanB
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Jan 3 at 12:26
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
hard to tell without your xpath, but could the xpath to the textarea change based on your click?
– Doug Clark
Jan 2 at 20:57
dont thought its important, i added it!
– Oleg Balan
Jan 2 at 21:08
add a comment |
This question already has an answer here:
Stale element exception python
2 answers
Selenium clicks one time, but next click returns StaleElementReferenceException
1 answer
Message: stale element reference: element is not attached to the page document in Python
1 answer
So I'm pretty new in Python and I tried something for my own, using selenium and firefox. But I got a StaleElementRefereceException when I want to type into a text field in firefox with selenium using send_key()
I tried a lot of Solutions like How to avoid "StaleElementReferenceException" in Selenium? but doesn't help me much because mine is not a click()
, it's a send_key
.
hshtg = "xyz"
driver = self.driver
driver.get(".......")
#time.sleep(3)
cmmnt_elem = driver.find_element_by_xpath('//textarea[@aria-label="Kommentar hinzufügen ..."]')
cmmnt_elem.click()
#time.sleep(3)
cmmnt_elem.send_keys(hshtg)
#time.sleep(3)
cmmnt_elem.send_keys(Keys.RETURN)
But, I got those errors.
File ".....py", line 45, in comment_photo
cmmnt_elem.send_keys(hshtg)
......
selenium.common.exceptions.StaleElementReferenceException: Message: The element
reference of <textarea class="Ypffh"> is stale; either the element is no longer
attached to the DOM, it is not in the current frame context, or the document
has been refreshed
tried this too: (cause of this: How to avoid "StaleElementReferenceException" in Selenium?)
attempts = 0
while attempts < 20:
try:
cmmnt_elem.send_keys(hshtg)
break
except Exception as e:
attempts+1
In case it's helpful, this is the field:comment field on instagram
python selenium browser
This question already has an answer here:
Stale element exception python
2 answers
Selenium clicks one time, but next click returns StaleElementReferenceException
1 answer
Message: stale element reference: element is not attached to the page document in Python
1 answer
So I'm pretty new in Python and I tried something for my own, using selenium and firefox. But I got a StaleElementRefereceException when I want to type into a text field in firefox with selenium using send_key()
I tried a lot of Solutions like How to avoid "StaleElementReferenceException" in Selenium? but doesn't help me much because mine is not a click()
, it's a send_key
.
hshtg = "xyz"
driver = self.driver
driver.get(".......")
#time.sleep(3)
cmmnt_elem = driver.find_element_by_xpath('//textarea[@aria-label="Kommentar hinzufügen ..."]')
cmmnt_elem.click()
#time.sleep(3)
cmmnt_elem.send_keys(hshtg)
#time.sleep(3)
cmmnt_elem.send_keys(Keys.RETURN)
But, I got those errors.
File ".....py", line 45, in comment_photo
cmmnt_elem.send_keys(hshtg)
......
selenium.common.exceptions.StaleElementReferenceException: Message: The element
reference of <textarea class="Ypffh"> is stale; either the element is no longer
attached to the DOM, it is not in the current frame context, or the document
has been refreshed
tried this too: (cause of this: How to avoid "StaleElementReferenceException" in Selenium?)
attempts = 0
while attempts < 20:
try:
cmmnt_elem.send_keys(hshtg)
break
except Exception as e:
attempts+1
In case it's helpful, this is the field:comment field on instagram
This question already has an answer here:
Stale element exception python
2 answers
Selenium clicks one time, but next click returns StaleElementReferenceException
1 answer
Message: stale element reference: element is not attached to the page document in Python
1 answer
python selenium browser
python selenium browser
edited Jan 2 at 22:13
Oleg Balan
asked Jan 2 at 20:46


Oleg BalanOleg Balan
63
63
marked as duplicate by DebanjanB
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Jan 3 at 12:26
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by DebanjanB
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Jan 3 at 12:26
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
hard to tell without your xpath, but could the xpath to the textarea change based on your click?
– Doug Clark
Jan 2 at 20:57
dont thought its important, i added it!
– Oleg Balan
Jan 2 at 21:08
add a comment |
hard to tell without your xpath, but could the xpath to the textarea change based on your click?
– Doug Clark
Jan 2 at 20:57
dont thought its important, i added it!
– Oleg Balan
Jan 2 at 21:08
hard to tell without your xpath, but could the xpath to the textarea change based on your click?
– Doug Clark
Jan 2 at 20:57
hard to tell without your xpath, but could the xpath to the textarea change based on your click?
– Doug Clark
Jan 2 at 20:57
dont thought its important, i added it!
– Oleg Balan
Jan 2 at 21:08
dont thought its important, i added it!
– Oleg Balan
Jan 2 at 21:08
add a comment |
1 Answer
1
active
oldest
votes
when you click
the textarea
the DOM will be modified, so it will give the error, there are two solution to fix it.
remove
click()
action
cmmnt_elem = driver.find_element_by_xpath('//textarea[@aria-label="Kommentar hinzufügen ..."]')
cmmnt_elem.send_keys(hshtg)
Re-search the element after click
cmmnt_elem = driver.find_element_by_xpath('//textarea[@aria-label="Kommentar hinzufügen ..."]')
cmmnt_elem.click()
cmmnt_elem = driver.find_element_by_xpath('//textarea[@aria-label="Kommentar hinzufügen ..."]')
cmmnt_elem.send_keys(hshtg)
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
when you click
the textarea
the DOM will be modified, so it will give the error, there are two solution to fix it.
remove
click()
action
cmmnt_elem = driver.find_element_by_xpath('//textarea[@aria-label="Kommentar hinzufügen ..."]')
cmmnt_elem.send_keys(hshtg)
Re-search the element after click
cmmnt_elem = driver.find_element_by_xpath('//textarea[@aria-label="Kommentar hinzufügen ..."]')
cmmnt_elem.click()
cmmnt_elem = driver.find_element_by_xpath('//textarea[@aria-label="Kommentar hinzufügen ..."]')
cmmnt_elem.send_keys(hshtg)
add a comment |
when you click
the textarea
the DOM will be modified, so it will give the error, there are two solution to fix it.
remove
click()
action
cmmnt_elem = driver.find_element_by_xpath('//textarea[@aria-label="Kommentar hinzufügen ..."]')
cmmnt_elem.send_keys(hshtg)
Re-search the element after click
cmmnt_elem = driver.find_element_by_xpath('//textarea[@aria-label="Kommentar hinzufügen ..."]')
cmmnt_elem.click()
cmmnt_elem = driver.find_element_by_xpath('//textarea[@aria-label="Kommentar hinzufügen ..."]')
cmmnt_elem.send_keys(hshtg)
add a comment |
when you click
the textarea
the DOM will be modified, so it will give the error, there are two solution to fix it.
remove
click()
action
cmmnt_elem = driver.find_element_by_xpath('//textarea[@aria-label="Kommentar hinzufügen ..."]')
cmmnt_elem.send_keys(hshtg)
Re-search the element after click
cmmnt_elem = driver.find_element_by_xpath('//textarea[@aria-label="Kommentar hinzufügen ..."]')
cmmnt_elem.click()
cmmnt_elem = driver.find_element_by_xpath('//textarea[@aria-label="Kommentar hinzufügen ..."]')
cmmnt_elem.send_keys(hshtg)
when you click
the textarea
the DOM will be modified, so it will give the error, there are two solution to fix it.
remove
click()
action
cmmnt_elem = driver.find_element_by_xpath('//textarea[@aria-label="Kommentar hinzufügen ..."]')
cmmnt_elem.send_keys(hshtg)
Re-search the element after click
cmmnt_elem = driver.find_element_by_xpath('//textarea[@aria-label="Kommentar hinzufügen ..."]')
cmmnt_elem.click()
cmmnt_elem = driver.find_element_by_xpath('//textarea[@aria-label="Kommentar hinzufügen ..."]')
cmmnt_elem.send_keys(hshtg)
answered Jan 3 at 3:14
ewwinkewwink
12.2k22440
12.2k22440
add a comment |
add a comment |
hard to tell without your xpath, but could the xpath to the textarea change based on your click?
– Doug Clark
Jan 2 at 20:57
dont thought its important, i added it!
– Oleg Balan
Jan 2 at 21:08