In my experience with various languages and how Selenium operates, I would anticipate something along these lines to be effective:
((IJavaScriptExecutor)driver).ExecuteScript(
"window.open(arguments[0], 'groupPage')", new Object[] { linkLocation });
(I am not familiar with coding in C#. I hope there are no glaring syntax errors in the code provided above.)
The ExecuteScript
method allows for an optional array of objects to be passed as arguments to the JavaScript code. On the browser side, the argument passed to ExecuteScript
is executed within a function, so the code snippet above can be interpreted as:
function () {
window.open(arguments[0], 'groupPage');
}
The type of string concatenation demonstrated in your self-answer is generally considered unsafe. If the `linkLocation` variable contains double quotes (which is possible, especially in query parameters), the concatenated string may result in invalid JavaScript code.