0

i am using python script to get browser height using selenium webdriver chrome..

print(browser.get_window_size())

which prints me: {'width': 1382, 'height': 744}

i would like to get only height from above..so for getting it i wrote below code:

data = browser.get_window_size(); print(data.height);

but i am getting error:

AttributeError: 'dict' object has no attribute 'height'

i am new to python, please help or suggest some other way.. thanks in advance..

Mohammed Sufian
  • 1,743
  • 6
  • 35
  • 62
  • 1
    `print(data['height'])`? [Dictionaries](https://docs.python.org/2/tutorial/datastructures.html#dictionaries) are pretty central to Python, so if you don't know how to use them you'll have a tricky time of it... – jonrsharpe May 15 '15 at 17:00
  • thanks a lot @jonrsharpe sir.. works perfect... for me.. thanks you save my time...and thanks too for the Dictionaries link... :) – Mohammed Sufian May 15 '15 at 17:02

2 Answers2

2

just do

print(data['height'])

please note, that you say you want to print width but in your example you are printing height, maybe you need

print(data['width'])
l0gg3r
  • 8,864
  • 3
  • 26
  • 46
0

Dictionary's elements are accessed with the [] operator:

print(data['height'])
Mureinik
  • 297,002
  • 52
  • 306
  • 350