SeleniumでOutlookの添付ファイルを追加する方法
解決したいこと
SeleniumVBAでOutlookのWEB版を操作しようとしています。
その中で添付ファイルを追加しようとするとエラーが出てしまい追加することができません。
どなたか解決方法をご存じの方がいらっしゃいましたらご教授ください。
発生している問題・エラー
エラー内容:
CssSelecterで"input[type='file']"を指定しているのですが、恐らくこのCssがメール本文に画像を貼り付ける要素のためテキストファイルが添付できないのだと思います。
出ているエラーメッセージ:
「次のファイルは、サポートされている種類の画像ファイルではないため、挿入されませんでした。: sample.txt。サポートされている画像ファイルの種類は、.png、gif、.bmp、.jpg、.jpe、.jfif、.jpegです。」
該当するソースコード
VBA&SeleniumVBAを使用しています。
下記のプログラムの
attachfile.SendKeys "C:\Users****\Desktop\sample.txt"
の部分で発生します。
--- プログラム ---------------------------------------------
Dim driver As SeleniumVBA.WebDriver
Dim keys As SeleniumVBA.WebKeyboard
Dim elm As WebElement
Set driver = SeleniumVBA.New_WebDriver
Set keys = SeleniumVBA.New_WebKeyboard
With driver
.StartEdge
.OpenBrowser
.NavigateTo "https://outlook.com/owa/technopro.com"
.Wait 5000
Set elm = .FindElement(By.CssSelector, "button[aria-label='新規メール']")
elm.Click
.Wait 3000
Dim attachfile As WebElement
Set attachfile = Nothing
Set attachfile = .FindElement(By.CssSelector, "input[type='file']")
attachfile.SendKeys "C:\Users\yoshi\Desktop\sample.txt" ' ←ここでエラー発生します。
End With
挿入→添付ファイルタグを表示させてみても、別のinput[type='file']も見つからず。。。