I want to decrease the zoom of the page to 80% at the start of a function, then perform some actions and then reset the zoom back to 100%. I am trying the following to decrease the zoom but its not working:
Press Key | xpath=//*[.='xyz'] | 17 | # Press Control
Press Key | xpath=//*[.='xyz'] | 45 | # Press minus key
Press Key | xpath=//*[.='xyz'] | 45 | # Press minus key
I guess what my code does is to send the keys one by one whereas it should send the keys all together. I am using Robot Framework and RIDE. I am trying to do the above for FireFox in Windows.
Also kindly guide me what library should I import if I want to use Press Key Native.
Ugh
I assume that we are talking about the Selenium2Library (Python). And your assumption is correct, it is sending the keys as independent events and therefore zoom doesn't work.
The bad news is that there is not keyword to do that. But there's a workaround available, but please note that changing the zoom level something else than 100% will most likely cause the selenium to interact with wrong elements.
Basically you need to write your own library keyword [1] to change the zoom, by extending the existing [2] Selenium2Library functionality. You need to get the driver object from the Selenium2Library and execute the code in below in your keyword.
driver.find_element(By.tag_name("html")).send_keys(Keys.chord(Keys.CONTROL, Keys.SUBTRACT))
Please note that all the code is untested and comes out of my memory, so it most likely contains errors.
But it should provide you an idea how one can do it. Feel free to ask more questions, if you do not get it working, because the example I provided is quite theoretical.
-Tatu
Send from my mobile
[1] http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#creating-test-libraries
[2] http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#extending-existing-test-libraries
--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.
To post to this group, send email to robotframe...@googlegroups.com.
Visit this group at http://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.
Execute javascript document.body.style.zoom="70%"
sleep 3
#reset:
Execute javascript document.body.style.zoom="0%"
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsub...@googlegroups.com.