如何使用selenium和python 3.x在这个网站中缩小?

时间:2017-11-12 01:02:55

标签: python-3.x selenium-webdriver zooming

我需要你的帮助。我想缩小地图,我不知道该怎么做。你能跟我说点什么吗?

<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>

我试过了:

browser.find_elements_by_name("zoom_out")

不幸的是它不起作用。

1 个答案:

答案 0 :(得分:0)

我做到了。解决方案是:

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