SeleniumBasic UtilsClass 便利機能の利用

リファレンス

便利機能関数クラスの解説です。直接SelectBasicで扱うブラウザ操作とは関係ない関数群になります。

オブジェクト設定

・変数宣言

Dim Utils As New Utils

文法

Utils.[メソッド]

メソッド・プロパティ

メソッド

スクロールできます
Name解説ShortExample
IsMatch正規表現による部分一致検索で一致した場合、Trueを返す。Debug.Print "IsMatch: " & Utils.IsMatch(str, "hoge*")
Match正規表現による部分一致検索で一致した場合、検索値を返す。Debug.Print "Match: " & Utils.Match(str, "hoge", 0)
Matches正規表現による部分一致検索で一致した場合、検索値をリストで返す。Set List = Utils.Matches(str, "hoge")
ReplaceVBAのReplace関数と同じ使い方Debug.Print "Replace: " & Utils.Replace(str, "hoge", "")
SendKeysNatWindows の SendKeys メソッドと同様の使い方
TakeScreenShotデスクトップのスクリーンショット撮影Set img = Utils.TakeScreenshot()

※Short Exampleは、動作確認ができたコードを記載しています。

Example

Use_UtilsCls_Match

Private Sub Use_UtilsCls_Match()
    Dim Utils As New Utils
    Dim List As New List
    Dim str As String
    str = "hogeagesagehogehoge"
    
    Debug.Print "IsMatch: " & Utils.IsMatch(str, "hoge*")
    Debug.Print "Match: " & Utils.Match(str, "hoge", 0)
    Debug.Print "Replace: " & Utils.Replace(str, "hoge", "")
    
    Set List = Utils.Matches(str, "hoge")
    Debug.Print "List1: " & List.Item(1)
    Debug.Print "List2: " & List.Item(2)
    Debug.Print "List3: " & List.Item(3)
End Sub

Use_UtilsCls_other

Private Sub Use_UtilsCls_other()
    Dim Keys As New Keys
    Dim driver As New ChromeDriver
    Dim Utils As New Selenium.Utils
        
    driver.Get "https://en.wikipedia.org/wiki/Main_Page"
    Dim img As Selenium.Image
    Set img = Utils.TakeScreenshot()
'    img.Copy
    img.ToExcel
    Stop
    driver.Quit
End Sub
よかったらシェアしてね!
  • URLをコピーしました!
  • URLをコピーしました!

この記事を書いた人

VBAを中心とした自動化、効率化の手法を紹介しています。現在は、SeleniumBasicのexamplesを紹介しています。その内、SeleniumBasic以外の手法も掲載したいと思っております。