I have an issue that I cannot seem to resolve. I am writing an automated testing application in Java using JUnit/Selenium with Appium to test a website in the iOS simulator (Mobile Safari).
In this automated testing application I want to run some tests, rotate the device and run another set of tests. I've got everything working correctly except the rotation piece.
I found the following thread on how to rotate the iOS device in which someone suggested using the following Java code:
WebDriver augmentedDriver = new Augmenter().augment(driver);
((Rotatable)augmentedDriver).rotate(ScreenOrientation.LANDSCAPE);
However I am getting the following cast exception:
java.lang.ClassCastException: org.openqa.selenium.remote.RemoteWebDriver cannot be
cast to org.openqa.selenium.Rotatable
Has anyone else encountered this issue and know a fix/workaround? Maybe using Appium's JSON wire protocol?
Any help is greatly appreciated.
Thanks!
OK, so I finally figured out the issue. Annoying that after hours of searching and trying different things it was a very simple solution.
All that is needed is the following Capability:
cap.setCapability("rotatable", true);
Then use the following code to rotate the device:
WebDriver augmentedDriver = new Augmenter().augment(driver);
((Rotatable)augmentedDriver).rotate(ScreenOrientation.LANDSCAPE);
YEAH! Problem solved!
Rotation is not implemented and this request is marked as "won't fix". Check here.
As far as i know, this is because rotating screen is already implemented in Appium so yes, check the Appium API for solution. Alternatively you can try to execute javascript, something together with target.setDeviceOrientation, but I would go with the first one.
Related
I have hit a brick wall here; I am completely unable to run any selenium tests on Chrome, as every time I launch it, the chrome browser will open and hang for 600 seconds, with Data:, in the address bar. I have tried every solution under the sun found so far on stack overflow.
Verified the versions between ChromeDriver and Chrome browser - yes they match.
Uninstalled/reinstalled chrome several times, and also verified the versions match.
The interesting thing is that running the tests on Microsoft Edge work fine, which leads me to believe there could be an issue with Chrome/Chromedriver not having the correct permissions? The machine the tests are running on is managed by my company. Any and all help would be greatly appreciated here.
Thanks :)
I think your issue is in the configuration of the WebDriver object.
If you use Maven, there is a library which helps configuring the webdrivers. Or if you aren't, then you can download the .jar file and add it to your build path.
https://github.com/bonigarcia/webdrivermanager
With this, you don't need to download the driver file itself and set the system property for it's value.
Here is a quick example for creating the ChromeDriver object:
WebDriverManager.chromedriver().setup();
WebDriver driver = new ChromeDriver();
The same thing on Edge:
WebDriverManager.edgedriver().setup();
WebDriver driver = new EdgeDriver();
Try this at your WebDriver configuration and maybe it can help!
Happy coding! :)
I have solved this problem - the administrators of the computers I was using had not given access to Chrome's developer tools. After getting access, the problem had gone away. Hope this helps anyone else who encounters this problem :)
Hello, I am getting this error when trying to run my java app in VS Code. I am trying to run an app that works with an instantiable class. This seems to only have started happening today for some reason.
I am a noob and will need some dumbed-down help, please.
I have tried the below links but they haven't helped:
Problem to run chrome debugger in VS Code (This does not work for me)
https://support.apple.com/en-gb/HT208050 (I did this and it doesn't change anything)
This comes up in my VS Code terminal:
The default interactive shell is now zsh.
To update your account to use zsh, please run chsh -s /bin/zsh.
For more details, please visit https://support.apple.com/kb/HT208050.
It is working now after powering off and back on. One of the above two links must have done the job. Sorry, lol.
I am working on a webpage automation (using selenium webdriver in python) where I need to upload a file.
I am working on mac and tried the following approaches:
- I tried using send_keys but the same didn't work (threw following error: cannot focus element
- AutoIt doesn't work since it is MAC.
I came across java.awt.robot to get this kind of thing work but is there anything similar which is available for python.
An example will help me a lot.
Thanks in Advance!
I do not have enough reputation to comment. Please refer to this below post:
Is there a sendKey for Mac in Python?
I'm trying to do a test that involves browser zooming in Selenium (Java). The following was my approach:
WebElement html = m_webDriver.findElement(By.tagName("html"));
html.sendKeys(Keys.chord(Keys.CONTROL, Keys.ADD));
This worked fine in IE, but causes an exception in Chrome saying "cannot focus element", which happens whenever I attempt to send any keys in Chrome.
The following sources have also had similar issues, but no workaround listed works for me:
https://sqa.stackexchange.com/questions/2023/webdriver-api-failed-to-send-keys-because-cannot-focus-element-better-work
https://code.google.com/p/selenium/issues/detail?id=2328&noredir=1
Thanks!
I'm not 100% sure, but it is probably best to use JavaScript for that.
Something along the lines of:
driver.executeScript("document.body.style.zoom=1.0"); // or 0.9 or whatever
I read the nebeans tutorial for RESTfull service (http://netbeans.org/kb/docs/websvc/rest.html) and tried to implement it. But when i'm run the test I'm not getting the screen what they say. I found that some say it is a bug on netbeans whilst some say it is bug on browser.I read some related question on this site but could not get much help
Suppose to appear as previous one
but appear as following one....
Note that navigation is not appears.
I'm unable to get the test it further.
I'm using netbeans 7.1 bundle
Can any one help me out. Thank you.
p.s : This page opens as reading a file( file:///home/xxx/xxx )
In that link you can notice the caution
Caution: For later versions of Firefox, you need to generate the test client in another Java web application than the service project.
I got the same error in firefox and chrome, then I tried test-resbeans.html in IE and its working fine as mentioned.
That tutorial dose't work on that way. When we test the restfull test we need to brows and give that restfull service. Then it will work on any browser.(I guess to test it need a service).