Search code examples
pythonpython-2.7seleniumselenium-webdriversplinter

Selenium — visiting URL with global variables


Suppose I have a config.cfg file with the following:

[Info]
keyword: Cool Shirt

How would I pass keyword into a URL, such that

driver.get("http://www.somewebsite.com/checkout?keyword")

achieves the same result as

driver.get("http://www.somewebsite.com/checkout?keyword=Cool+Shirt")?


Solution

  • You can read your keyword value from config file "opencodez.com/java/read-config-file-in-java.htm"; using this way and then pass it into string formater to build string as you want

    String URL=String.format("somewebsite.com/checkout?%s",keyword);