0

On the website I do have "enableTab = false". For the testing purpose, i'm using Chrome with Console developer tool. What I need to do is to set enableTab = false, then refresh the browser and see the result. I try to set directly in console "enableTab = true" then refresh the page, but the variable automatically changes back to false.

I can test it manually by setting the enableTab in the code, but it becomes more time-consuming when I have to redo the task with many other flags.

Is it anyway that I can set the "enableTab = true" in the console, then make sure it's always set to true when I browse around the website (after refresh).

Thank you

2
  • Set a breakpoint in top of a file. Commented Jan 25, 2016 at 19:09
  • Exactly what I need, thank you Commented Jan 25, 2016 at 19:13

2 Answers 2

1

try initilizing and setting your variables from localStorage.

in your initializing code try something like:

enableTab = localStorage[0] || false;

then when you want to test what it will look like, in the console you would type:

localStorage[0] = true;

and refresh the page.

Sign up to request clarification or add additional context in comments.

1 Comment

thanks, it would be a nice approach but I try not to touch the code as much as possible because I will need to clean up later. So the above answer which asks to set breakpoint is really what i need.
0

You can add parameters to the URL. For example, if your URL is http://hostname/path, replace it by http://hostname/path?enabledTab=true, and then inside your web page include this:

enableTab = location.search.includes('enabledTab=true')

The nice thing about the URL approach is that it is easy to use in manual testing scenarios like you described, and also in automatic testing scenarios where you want a test script to control the behavior of the application.

3 Comments

The url itself has already had a query so I guess it will make it more complicated. thanks!
It's o.k. to add more parameters to an existing query
new thing to try and i will do that, thank for the knowledge!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.