前提
(質問投稿初めてのため、不足情報などありましたらすみません)
PythonのSeleniumでWebページの操作を行うプログラムを書いているのですが、以下のエラーがどうしても解決できず、どなたかご教示をいただけますと幸いです。
操作したいWebページが、TableauというBIツールでifameが使われているなど、やや複雑な構造となっております。
実現したいこと
・ダッシュボードの日付フィルターに週数を入力して、データを更新したい。
(send_keysでテキストを入力したい)
発生している問題・エラーメッセージ
・send.keysでテキストを入力しようとすると、下記のエラーメッセージが出て実行できません。
・.clickや.textは実行ができるため、指定しているxpathは間違っていないと思われます。
python
1ElementNotInteractableException Traceback (most recent call last) 2Input In [14], in <cell line: 2>() 3 1 weekinput = driver.find_element_by_xpath('//*[@id="tableau_base_widget_LegacyQuantitativeQuickFilter_0"]/div/div[2]/div[2]/input') 4----> 2 weekinput.send_keys('33') 5 6File c:\users\yuuka\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webelement.py:540, in WebElement.send_keys(self, *value) 7 537 remote_files.append(self._upload(file)) 8 538 value = '\n'.join(remote_files) 9--> 540 self._execute(Command.SEND_KEYS_TO_ELEMENT, 10 541 {'text': "".join(keys_to_typing(value)), 11 542 'value': keys_to_typing(value)}) 12 13File c:\users\yuuka\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webelement.py:710, in WebElement._execute(self, command, params) 14 708 params = {} 15 709 params['id'] = self._id 16--> 710 return self._parent.execute(command, params) 17 18File c:\users\yuuka\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:424, in WebDriver.execute(self, driver_command, params) 19 422 response = self.command_executor.execute(driver_command, params) 20 423 if response: 21--> 424 self.error_handler.check_response(response) 22 425 response['value'] = self._unwrap_value( 23 426 response.get('value', None)) 24 427 return response 25 26File c:\users\yuuka\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py:247, in ErrorHandler.check_response(self, response) 27 245 alert_text = value['alert'].get('text') 28 246 raise exception_class(message, screen, stacktrace, alert_text) # type: ignore[call-arg] # mypy is not smart enough here 29--> 247 raise exception_class(message, screen, stacktrace) 30
該当のソースコード
python
1 2week = driver.find_element_by_xpath('//*[@id="tableau_base_widget_LegacyQuantitativeQuickFilter_0"]/div/div[2]/div[2]/input') 3week.send_keys('33')
試したこと
・xpath以外にもidやclass nameなどでも試しましたが全てエラーとなってしまいました。
・inputタグの1つ上の階層のdivタグの方は.click()で選択することができましたが、inputタグの方はclickもsend_keysもできない状況です。
・このダッシュボードはiframeが使われていたため、最初に下記のコードでiframe内の操作に切り換えています。(切り替える前はclickもできませんでしたが、切り換えることで操作ができるようになりました)
python
1iframe = driver.find_element_by_xpath('//*[@id="viz"]/iframe') 2driver.switch_to.frame(iframe)
補足情報(FW/ツールのバージョンなど)
ご参考に、週数を入力したい箇所のhtmlを記載いたします。
html
1<div class="QFReadout QFUpperBound tab-ctrl-formatted-border-hover active" dojoattachevent="onclick:showUpperInput" dojoattachpoint="domUpperBound" style="width: 74px;"><div class="readoutText tab-ctrl-formatted-fixedsize" dojoattachpoint="domUpperText" style="display: none;">32</div><input type="text" dojoattachpoint="domUpperInput" style="width: 74px;"></div> 2 3 <div class="readoutText tab-ctrl-formatted-fixedsize" dojoattachpoint="domUpperText" style="display: none;">32</div> 4 5 <input type="text" dojoattachpoint="domUpperInput" style="width: 74px;"> 6 7<div dojoattachpoint="domBar" class="QFSlider QFBar" style="width: 140px; top: 28px; left: 12px;"><div dojoattachpoint="domRange" class="QFRange" dojoattachevent="onmousedown:startRangeCapture" style="left: 0px; width: 85px;"><div dojoattachpoint="domHighlight" class="QFRangeHighlight" style="visibility: hidden; left: 0px; width: 85px;"></div></div></div> 8

回答1件
あなたの回答
tips
プレビュー
下記のような回答は推奨されていません。
このような回答には修正を依頼しましょう。
また依頼した内容が修正された場合は、修正依頼を取り消すようにしましょう。
2022/08/24 14:07
2022/08/25 00:52 編集
2022/08/31 12:36
2022/09/01 11:19
2022/09/06 13:20