Search code examples
python-3.xselenium-webdriverzooming

How to zoom out in this website using selenium and python 3.x?


I need your help. I would like to zoom out the map and I do not know how to do it. Can you tell me something?

<div draggable="false" style="-moz-user-select: none; box-shadow: 0px 1px 4px -1px rgba(0, 0, 0, 0.3); border-radius: 2px; cursor: pointer; background-color: rgb(255, 255, 255); width: 28px; height: 55px;">
   <div title="zoom_in" aria-label="zoom_in" tabindex="0" style="position: relative; width: 28px; height: 27px; left: 0px; top: 0px;">
      <div style="overflow: hidden; position: absolute; width: 15px; height: 15px; left: 7px; top: 6px;"><img style="position: absolute; left: 0px; top: 0px; -moz-user-select: none; border: 0px none; padding: 0px; margin: 0px; max-width: none; width: 120px; height: 54px;" src="https://maps.gstatic.com/mapfiles/api-3/images/tmapctrl.png" draggable="false"></div>
   </div>
   <div style="position: relative; overflow: hidden; width: 67%; height: 1px; left: 16%; background-color: rgb(230, 230, 230); top: 0px;"></div>
   <div title="zoom_out" aria-label="zoom_out" tabindex="0" style="position: relative; width: 28px; height: 27px; left: 0px; top: 0px;">
      <div style="overflow: hidden; position: absolute; width: 15px; height: 15px; left: 7px; top: 6px;"><img style="position: absolute; left: 0px; top: -15px; -moz-user-select: none; border: 0px none; padding: 0px; margin: 0px; max-width: none; width: 120px; height: 54px;" src="https://maps.gstatic.com/mapfiles/api-3/images/tmapctrl.png" draggable="false"></div>
   </div>
</div>

I tried:

browser.find_elements_by_name("zoom_out")

And unfortunately it does not work.


Solution

  • I did it. The solution is:

    browser.find_elements_by_xpath("//div[@title='zoom_out' and @aria-label='zoom_out']")