- My recorded step behaves differently in the different browsers.
- There is a specific action, which needs to be performed only in one type browser.
How can I set a step to run against specific browser only?
Test Studio strives to isolate you from browser differences, but in the cases when specific action or verification needs to be performed only for specific browsers, you can do so.
One quick solution is to include two separate steps and specify which browser each step will run against. All test steps include a RunsAgainst property setting:
The default is AllBrowsers. Copy your step and set one to InternetExplorerOnly, for example, and the other to FirefoxOnly. That way the specific step will execute only against the specified browser.
If you need to do a similar action in code, you can use code like this:
if (ActiveBrowser.BrowserType == BrowserType.InternetExplorer)
// Do IE specific action
else if (ActiveBrowser.BrowserType == BrowserType.FireFox)
// Do Firefox specific action
throw new ApplicationException("Unknown browser type");
' Do IE specific action
If ActiveBrowser.BrowserType = BrowserType.InternetExplorer Then
' Do Firefox specific action
ElseIf ActiveBrowser.BrowserType = BrowserType.FireFox Then
Throw New ApplicationException("Unknown browser type")