Excel VBA 質問スレッド №1571 (未解決)

SeleniumVBAについて

投稿者 : teteete     投稿日時 : 2023/09/18(Mon) 13:32:07     OS : 未指定     EXCEL : 未指定
chromeでVBAを用いてブラウザ操作をしたいと考えています。
その際に、プロファイルを変更しながら実施をしたいと思います。

Dim driver As New ChromeDriver
With driver


.AddArgument "--user-data-dir=" & Environ$("LOCALAPPDATA") & "\Google\Chrome\User Data"
.AddArgument "--profile-directory=Profile 4"


End With

この後に処理のコマンドを入れたのですが、ウィンドウがアクティブにならずに動きません。
どうやってアクティブにしたらよいのでしょうか?

スポンサーリンク
[返信 1] Re : SeleniumVBAについて
投稿者 : ごんぼほり     投稿日時 : 2023/09/19(Tue) 12:44:53
SeleniumVBAってどれでしょうか?
https://github.com/GCuser99/SeleniumVBA/tree/main
のことだとすると、プロファイルの切り替え方については、
https://github.com/GCuser99/SeleniumVBA/blob/main/test/test_Capabilities.bas
にサンプルが示されています

 Sub test_user_profile()
    Dim driver As SeleniumVBA.WebDriver
    Dim caps As SeleniumVBA.WebCapabilities

    Set driver = SeleniumVBA.New_WebDriver
    
    driver.StartEdge
    
    Set caps = driver.CreateCapabilities(initializeFromSettingsFile:=False)
    
    'this will create and populate a profile if it doesn't yet exist,
    'otherwise will use a previously created profile
    'recommended to customize your Selenium profiles in a different location
    'than the profiles in AppData to avoid conflicts with manual browsing
    'must specify the path to profile, not just the profile name
    caps.SetProfile ".\User Data\Edge\profile 1"
    
    driver.OpenBrowser caps
    
    driver.NavigateTo "https://www.wikipedia.org/"
    driver.Wait 1000
    
    driver.CloseBrowser
    driver.Shutdown
 End Sub

おっしゃっているSeleniumVBAがこれの事でなければごめんなさい

[返信 2] Re : SeleniumVBAについて
投稿者 : higeru     投稿日時 : 2023/09/19(Tue) 15:44:10
■[質問] teteeteさん(2023-09-18 13:32:07)の記事
> Dim driver As New ChromeDriver

とか

> .AddArgument "--user-data-dir=" & Environ$("LOCALAPPDATA") & "\Google\Chrome\User Data"

といった書き方からして「SeleniumVBA」ではないですね。なので当方確認できる環境がありませんが、コード自体は以下のページと同じです。

https://lil.la/archives/4594

 ここにはアクティブになるとかならないとかは書いていませんが、SwithToほにゃららメソッドでなんとかなりませんかね。

当掲示板について
  • Excel VBA に関する掲示板です。Excel VBA に関する質問や疑問、それに対する解決方法など気軽に投稿してください。
  • 記事内ではHTMLのタグは使用できません。
  • 記事は一度投稿すると修正できません。内容を訂正したい場合は返信で対応してください。
  • Sub〜End Sub、Function〜End Function は自動的にプログラムコードとみなし、枠で囲って見やすくします。
  • Excel VBA とは関係ないことや、他人が不快に思うようなことなど、管理人が適当でないと判断した記事は削除する場合があります。
スポンサーリンク
返信入力フォーム
お 名 前  :
内  容   :

ステータス  :

認証コード  : キャプチャ画像 




( 処理日時 : 2023-10-02 01:37:53 )
タイトルとURLをコピーしました