Skip to content

Modify Method. By, ToSelector #35

Open
@ghost

Description

FindElement, FindElementsで、XPath、LinkText、PartialLinkText を指定可能にした。
※TinySeleniumVBA v0.1.0 に対しては、XPath、LinkText、PartialLinkText が追加になる。
※TinySeleniumVBA v0.1.1 に対しては、LinkText、PartialLinkText が追加になる。

TinySeleniumVBA WebDriver.cls

Public Enum By
    ID = 0
    TagName = 1
    ClassName = 2
    Name = 3
    CssSelector = 4
    XPath = 5                   '2021/7/15 add ishi
    LinkText = 6                '2021/7/15 add ishi
    PartialLinkText = 7         '2021/7/15 add ishi
End Enum
' by* to CSS selector           '2021/7/15 chg ishi
Private Function ToSelector(by_ As By, _
                            ByVal value As String) As Dictionary
    Dim Data As New Dictionary
    Select Case by_
    Case By.ID
        Data.Add "using", "css selector"
        Data.Add "value", "[id=""" + value + """]"
    Case By.TagName
        Data.Add "using", "css selector"
        Data.Add "value", value
    Case By.ClassName
        Data.Add "using", "css selector"
        Data.Add "value", "." + value
    Case By.Name
        Data.Add "using", "css selector"
        Data.Add "value", "[name=""" + value + """]"
    Case By.CssSelector
        Data.Add "using", "css selector"
        Data.Add "value", value
    Case By.XPath
        Data.Add "using", "xpath"
        Data.Add "value", value
    Case By.LinkText
        Data.Add "using", "link text"
        Data.Add "value", value
    Case By.PartialLinkText
        Data.Add "using", "partial link text"
        Data.Add "value", value
    Case Else
        Data.Add "using", "css selector"
        Data.Add "value", value
    End Select
    
    Set ToSelector = Data
End Function

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions