Data loss after page refresh in selenium

0 votes
Hi i' am using selenium and when i input data in web page load and the data is lost ,can any one help me with the code how to handle data lose after page refresh
Apr 20, 2020 in Selenium by Darshan
• 120 points
3,062 views

2 answers to this question.

0 votes

In case you are talking about stopping the page loading in selenium, you could try these:

driver.findElement(By.tagName("body")).sendKeys("Keys.ESCAPE");

OR

JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("return window.stop");
answered Apr 20, 2020 by Sirajul
• 59,230 points
0 votes

The easiest way to reload current page without losing form data, use the WebStorage where you have -persistent storage (localStorage) or session based (sessionStorage) which remains in memory until your web browser is closed.

Something on these lines:

Try this when the page is about to reload,

window.onbeforeunload = function() {
   localStorage.setItem(name, $('#inputName').val());
   localStorage.setItem(phone, $('#inputPhone').val());
   localStorage.setItem(subject, $('#inputAddress').val());
}
answered Apr 20, 2020 by Liana

Related Questions In Selenium

0 votes
1 answer
0 votes
2 answers

Unable to Click on an Element in Selenium (Python) even after finding it.

Here, I give you working script which ...READ MORE

answered Sep 19, 2018 in Selenium by Priyaj
• 58,100 points
23,971 views
0 votes
2 answers

How to scroll the Page up or down in Selenium WebDriver? (using java)

JavascriptExecutor jsx = (JavascriptExecutor)driver; jsx.executeScript("window.scrollBy(0,555)", ""); or Action classes ...READ MORE

answered Sep 6, 2020 in Selenium by Sri
• 3,190 points
18,816 views
0 votes
1 answer

Reading data from Excel in my Selenium test

Log4j problems are usually thrown because of ...READ MORE

answered Apr 6, 2018 in Selenium by nsv999
• 5,500 points
10,565 views
0 votes
1 answer
0 votes
1 answer

Page Object Pattern in Selenium WebDriver

Check below links: Documentation: Page Objects and PageFactory  Page Object Design Pattern  Other ...READ MORE

answered Apr 17, 2018 in Selenium by Vardy
• 2,360 points
987 views
0 votes
1 answer

Login page test script using selenium and java in Eclipse IDE

Here is an example to login to ...READ MORE

answered Apr 23, 2018 in Selenium by Meci Matt
• 9,460 points
13,686 views
+3 votes
1 answer

How to read excel file numeric data of all rows and column in selenium? I have 10 rows and 5 column but I read Only String value not a Numeric value?

Hey, @Mahendra, check this thread https://www.edureka.co/community/52170/read-numeric-data-from-excel-sheet-using-selenium-webdriver It deals with ...READ MORE

answered Jan 27, 2020 in Selenium by Sirajul
• 59,230 points
2,003 views
0 votes
3 answers

How to stop a page loading from selenium in chrome?

Hi Savan, Setting the pageLoadStrategy capability to none. Then wait for ...READ MORE

answered Jul 7, 2020 in Selenium by Suhana

edited Jul 7, 2020 6,933 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP