Reputation: 1
I am testing a webMobile version of a website. I need to change the screen orientation to landscape, but I can not find any appropriate code.
Here is what I did:
((IJavaScriptExecutor)driver).ExecuteScript("document.querySelector('meta[name=viewport]').setAttribute('content', 'width=device-height, height=device-width, initial-scale=1');");
var frame = wait.Until(e => e.FindElement(By.Id("gameFrame")));
driver.SwitchTo().Frame(frame);
var elem = wait.Until(e => e.FindElement(By.CssSelector(".buttonLabel.leftButtonLabel")));
((IJavaScriptExecutor)driver).ExecuteScript("arguments[0].scrollIntoView(true);", elem);
if (elem.Displayed)
{
action.MoveToElement(elem).Click().Perform();
}
This changed to landscape but it only changed the viewport, and the elements became not interactable.
Do you have any solution for this in C# Selenium?
Upvotes: 0
Views: 45