-1

Hope if someone could help. I am working on an Angular based application. I am automating my End to End tests with the help of Protractor. I have a global variable set in my Application called "selectedPlatform", which conveys, for which platform(iOS/Android) I have my current application build for.

I need to access this variable for me write my test cases accordingly. Any help on this ground is greatly appreciated.

Thanks, Madhan

  • You've been down voted so your question will probably be deleted. Anyway, even globals are evil, is as simple as referencing like this: `global.selectedPlatform` good luck. – Leo Gallucci Oct 07 '14 at 19:33
  • Hey Leo,Thanks for your response! But, I am unable to get to see the value of my variable when I accessed it as you mentioned above. Please clarify – user3128287 Oct 07 '14 at 23:09
  • As well, I am in the process of injecting the service which holds my choice of platform while building. But, I am not pretty sure how I can implement that in protractor. Could you advise on that please? – user3128287 Oct 07 '14 at 23:13

1 Answers1

2

If I understand correctly, your variable is a global inside your website, i.e. it's on window. Generally, your end to end tests should avoid accessing variables directly in your site's code, but if you have to do this you can do:

browser.executeScript('return window.selectedPlatform')
Jmr
  • 12,078
  • 4
  • 39
  • 33