Interacting with iFrames Using Splinter/Selenium [Python] Interacting with iFrames Using Splinter/Selenium [Python] selenium selenium

Interacting with iFrames Using Splinter/Selenium [Python]


You primary problem seems to be that you are treating the results of browser.find_by_xxx as an element object, when in reality it is an element container object (i.e. a list of webdriver elements).

Writing to the field works for me if I reference the element explicitly:

In [51]: elems = browser.find_by_id('tweet-box-global')In [52]: len(elems)Out[52]: 1In [53]: elems[0].fill("Splinter Example")In [54]:

That will write "Splinter Example" into the field for me.

The button click is failing because your css path is returning a list of three elements, and you are implicitly clicking on the first, hidden element. In my testing, the element you actually want to click on is the second element in the list:

In [26]: elems = browser.find_by_css('.btn.primary-btn.tweet-action.tweet-btn.js-tweet-btn')In [27]: len(elems)Out[27]: 3In [28]: elems[1].click()In [29]:

When I explicitly click the second element it doesn't throw an error and the button is clicked.

If you add to the css path you can narrow the results to only the button in the visible modal:

In [42]: css_path = "div.modal-tweet-form-container button.btn.primary-btn"In [43]: elems = browser.find_by_css(css_path)In [44]: len(elems)Out[44]: 1In [45]: elems.click()In [46]:

Note that no exception was thrown here.