2017-07-16 3 views
1

内のテキストを記入してください。 CRMの電子メールエディタはiframe内にあります。私はsplinterでiframeを見つけることができますが、私はエディタに何かを書くことができません。ここでPythonは破片、私は破片でautoraptorのCRMを自動化することだし、それがメッセージを作成するための時間が来たまで、すべてがスムーズに実行していたのiframe


私はここでFrames, alerts and prompts

を読んだことがHTML

<div id="cke_1_contents" class="cke_contents cke_reset" role="presentation" style="height: 200px;"><span id="cke_67" class="cke_voice_label">Press ALT 0 for help</span><iframe src="" frameborder="0" class="cke_wysiwyg_frame cke_reset" title="Rich Text Editor, email_body" aria-describedby="cke_67" tabindex="0" allowtransparency="true" style="width: 100%; height: 100%;"></iframe></div> 

は、Python


#!/usr/bin/env python 

from splinter import Browser 
import urlparse 
import time 

# Creds 
username = "[email protected]" 
password = "spamspamspam..." 

login_url = 'https://ar.autoraptor.com/login' 

browser = Browser('chrome') 

#help(browser) 

# Go to login page 
browser.visit(login_url) 

# Fill in Username 
browser.find_by_name('login').fill(username) 

# Fill in 
browser.find_by_name('password').fill(password) 

# Click the login Button 
browser.find_by_value('Log In').click() 

# Navigate to upsheets 
#browser.find_by_xpath('//*[@id="nav"]/li[4]/a').click() 

# Navigate to least updated upsheets 
url = "https://ar.autoraptor.com/upsheets?filter=active&sort=updated_at%5B1%5D" 
browser.visit(url) 

# Click on notifications 
browser.find_by_xpath('//*[@id="nav"]/li[8]/div[1]').click() 
time.sleep(5) 

# Click on email 
browser.find_by_xpath('//*[@id="notification-tab-incoming_email"]/div').click() 
time.sleep(5) 

# Read email 
browser.find_by_text("Email from ").click() 

# Send email 
browser.find_by_id('newemailplaceholder').click() 
time.sleep(5) 
browser.find_by_id("cke_1_contents").fill("ftw") 
#browser.quit() 
0123です

ここでトレースバックが

Traceback (most recent call last): 
    File "testbot.py", line 50, in <module> 
    browser.find_by_id("cke_1_contents").find_by_tag("iframe").fill("foo") 
    File "/home/ricky/.local/lib/python2.7/site-packages/splinter/driver/webdriver/__init__.py", line 529, in fill 
    self.value = value 
    File "/home/ricky/.local/lib/python2.7/site-packages/splinter/driver/webdriver/__init__.py", line 511, in _set_value 
    self._element.clear() 
    File "/home/ricky/.local/lib/python2.7/site-packages/selenium/webdriver/remote/webelement.py", line 92, in clear 
    self._execute(Command.CLEAR_ELEMENT) 
    File "/home/ricky/.local/lib/python2.7/site-packages/selenium/webdriver/remote/webelement.py", line 493, in _execute 
    return self._parent.execute(command, params) 
    File "/home/ricky/.local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 256, in execute 
    self.error_handler.check_response(response) 
    File "/home/ricky/.local/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 194, in check_response 
    raise exception_class(message, screen, stacktrace) 
selenium.common.exceptions.InvalidElementStateException: Message: invalid element state: Element must be user-editable in order to clear it. 
    (Session info: chrome=59.0.3071.115) 
    (Driver info: chromedriver=2.30.477691 (6ee44a7247c639c0703f291d320bdf05c1531b57),platform=Linux 4.10.0-26-generic x86_64) 
+0

あなたのコードを投稿してください。試してみるとどうなりますか? – Guy

+0

iframe内の要素を消去する代わりに、まずそれを選択できますか?それは内容を取得する?そうでない場合は、iframeへの切り替えが成功しておらず、それがあなたに集中する必要があります。 –

答えて

0

だ例外の理由は、iFrameをの場合でも、HTML5属性contenteditable="true"で入力することができないということです。 HTMLを自由にコントロールできたら、これを試してください。上の属性があれば、実際に段落を編集できることがわかります。どのようなHTMLがあなたのコントロールの外にある場合、あなたが行うことができるかもしれないと、あなたはそれと対話することができます内の要素iFrameを(1があるかどうか)を見つけるです。 iframe内に要素がない場合、マウス/キーボードコントローラのIframeとやりとりする手段に頼る必要があります。これは、物理的にマウスを動かし、キーストロークをシミュレートすることを意味します。

<div id="cke_1_contents" class="cke_contents cke_reset" role="presentation" style="height: 200px;"> 
    <span id="cke_67" class="cke_voice_label">Press ALT 0 for help</span> 
    <iframe src="" frameborder="0" class="cke_wysiwyg_frame cke_reset" title="Rich Text Editor, email_body" aria-describedby="cke_67" tabindex="0" allowtransparency="true" style="width: 100%; height: 100%;"></iframe> 
     <p contenteditable="true">Begin with some text</p> 
</div> 
+0

は、私は多分私はインクルードがHTMLを改ざん可能性がプロキシを書くことができ、CRMは、第三者https://www.autoraptor.com/ –

+0

によって所有されたHTMLを制御することはできません。 –

+0

今すぐプロキシを書く –

関連する問題