Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8609781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T03:57:50+00:00 2026-06-12T03:57:50+00:00

I am a newbie programmer, very newbie.. I am trying to write a program

  • 0

I am a newbie programmer, very newbie..

I am trying to write a program to test our website and am using Java and Selenium.

The issue is I want to create a “table” or a “reference” that will allow me to store variables that can easily be called back and used in different calls.

I tried to use a HashMap but found it was no good because when I rerun my testing code there is a new hashmap each time. I want something that can store the values and remember them the next time I run the code.

I looked at creating a mysql table but I can’t figure out how to recall the variables out of the table once they have been created.

I hope this makes some sense. :0) Pls check out below if an example would be more useful
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Here is an example of the hashmap that I was using:

HashMap idTable = new HashMap();
idTable.put("GroupName", new String("Group " + 
              Long.toHexString(Double.doubleToLongBits(Math.random()))));
element = driver.findElement(By.id("name"));
element.sendKeys((String)idTable.get("GroupName"));

FYI: The reason this doesn’t work for me is that I want to be able to wrap it in an “if” statement; to tell the computer that if the variable called “GroupName” already exists then don’t do it again.. however every time I run the script I make a call to the function [HashMap idTable = new HashMap();] and I don’t know how to NOT make that call because the HashMap isn’t saved anywhere.. it is created new each time.

Thanks,
Orli

not sure where to add this: but following the first suggestion here is what I did.

HashMap idTable;

try{

ObjectInputStream is = new ObjectInputStream(

new FileInputStream(“C:\Documents and Settings\My Documents\Selenium local\hashmap.dat”));

idTable = (HashMap) is.readObject();

}

catch(Exception e){

idTable = new HashMap();

}

AND then:

try{

ObjectOutputStream os = new ObjectOutputStream (

new FileOutputStream(“C:\Documents and Settings\My Documents\Selenium local\hashmap.dat”));

os.writeObject(idTable);

os.close();

}

catch (Exception e){

}

It works. :0) Thanks for the help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T03:57:52+00:00Added an answer on June 12, 2026 at 3:57 am

    You must store them somewhere not in the code, as the code goes bye-bye whenever the JVM shuts down. Two good options to do this are

    • Using SQL database, research this more via google if you want
    • Via files, simply writing your HashMap database to a file at the end of your program (Do Runtime.addShutdownHook, and pass it a thread whcih stores your hashmap to the file), and have it read from the file at the begining of the code (if the file is nonexistant, make a new one, and store an empty hashmap to it)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Newbie in testing. I generated a test case using Selenium, and then exported it
Newbie C++ programmer here. I'm trying to write a command line application that takes
i am e newbie programmer and i want to improve a student program for
I am a Selenium newbie ... As a JavaScript programmer, I think I want
I am newbie programmer in cocos2D.... I wanted to create the Endless Background using
I'm a newbie programmer writting a program in MonoDevelop in C# and have a
I'm a newbie programmer trying to find my way in the world. I've got
i am a newbie C# Programmer. I have a problem in xhtml. I want
PHP Redirect with Post Data Hi, I am a newbie PHP programmer and trying
Hello Friends I am a newbie programmer and very very new to PHP. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.