1

I'm using watir-webdriver to do my GUI smoke tests, and one area I'd like to test out is redirecting from a dynamic url

Is it possible to save the url to a file, then load it for use?

What I'm thinking of in pseudo code:

@browser.goto 'google.com'
@browser.url.save

in another test

@browser.load url
continue testing....

Is there a way to do this?

1
  • 1
    Also, watir-webdriver gem has been deprecated in favor of the watir gem. Update to to Watir 6 to get access to all of the new features. Commented Mar 6, 2017 at 23:11

1 Answer 1

1

To write a string to a file you can just do that:

 File.open('path/to/yourfile', 'w') { |file| file.write(@browser.url) }

You can use it in the other test like this:

File.open('path/to/yourfile', "rb") { |file| @browser.goto(file.read) }
Sign up to request clarification or add additional context in comments.

1 Comment

Oh wow, I pretty much facepalmed as soon as I read your answer. Yup, this definitely works!

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.