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 19 in Selenium by Darshan
• 120 points
55 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 19 by Sirajul
• 53,080 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 19 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
• 57,530 points
13,929 views
0 votes
1 answer

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

Its pretty simple. Check out the below ...READ MORE

answered Apr 5, 2018 in Selenium by nsv999
• 5,510 points
11,812 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,510 points
7,106 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,370 points
260 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
5,048 views
0 votes
1 answer

Identifying the page iframe in Selenium using Java Code

Open the page in a browser and ...READ MORE

answered May 24, 2018 in Selenium by Samarpit
• 5,870 points
336 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 in Selenium by Sirajul
• 53,080 points
243 views
+2 votes
2 answers

Unable to derive module descriptor for C:\Selenium\selenium-server-standalone-3.9.1.jar. Provider class org.apache.bsf.BSFManager not in module

The InvalidModuleDescriptorException usually occurs when you are trying to read ...READ MORE

answered Jan 27 in Selenium by Sirajul
• 53,080 points
2,272 views