注意:Selenium或API封裝的解決方案Splinter for Selenium很好!使用Splinter/Selenium與iFrames交互[Python]
我一直在使用Python的Splinter API與Twitter.com上的iframe進行交互。
例如,
with Browser('firefox', profile_preferences= proxySettings) as browser:
#...login and do other stuff here
browser.find_by_id('global-new-tweet-button').click()
這帶來了一個彈出框鍵入在鳴叫。
如何與這個新的箱體採用分裂互動: 1)在消息 2)單擊「鳴叫」填寫(提交) ..programmatically當然。
我試着檢查元素,但它似乎並不嵌套在iframe中,但是它的目標是一個iframe。所以我不確定如何找到/與這個彈出窗口中的元素進行交互。
我試過手動在郵件中鍵入然後單擊鳴叫按鈕編程:
browser.find_by_css('.btn.primary-btn.tweet-action.tweet-btn.js-tweet-btn').click()
..但我得到的錯誤:
ElementNotVisibleException: Message: Element is not currently visible and so may not be interacted with
Stacktrace:
at fxdriver.preconditions.visible (file:///var/folders/z1/8rqrglqn2dj8_yj1z2fv5j700000gn/T/tmppRsJvd/extensions/[email protected]/components/command-processor.js:10092)
at DelayedCommand.prototype.checkPreconditions_ (file:///var/folders/z1/8rqrglqn2dj8_yj1z2fv5j700000gn/T/tmppRsJvd/extensions/[email protected]/components/command-processor.js:12644)
at DelayedCommand.prototype.executeInternal_/h (file:///var/folders/z1/8rqrglqn2dj8_yj1z2fv5j700000gn/T/tmppRsJvd/extensions/[email protected]/components/command-processor.js:12661)
at DelayedCommand.prototype.executeInternal_ (file:///var/folders/z1/8rqrglqn2dj8_yj1z2fv5j700000gn/T/tmppRsJvd/extensions/[email protected]/components/command-processor.js:12666)
at DelayedCommand.prototype.execute/< (file:///var/folders/z1/8rqrglqn2dj8_yj1z2fv5j700000gn/T/tmppRsJvd/extensions/[email protected]/components/command-processor.js:12608)
我嚴格想用這樣分裂來實現我的目標請不要提供替代方案,我知道還有其他方法。 提前謝謝!