'How do I select an element from webpage that doesn't have Id or Name?

Sub TestSelenium()
    Set MyBrowser = New Selenium.ChromeDriver
    MyBrowser.Start
    MyBrowser.Get 
"https://www.business.tax.virginia.gov/VTOL/tax/Login.xhtml"
# Entering in credentials
    MyBrowser.FindElementByName("loginForm:customerType").Click
    MyBrowser.FindElementById("loginForm:customerNumber").SendKeys "00-0000000"
    MyBrowser.FindElementById("loginForm:userName").SendKeys "0000000000"
    MyBrowser.FindElementById("loginForm:password").SendKeys "000000"
    MyBrowser.FindElementByName("loginForm:loginButton").Click

# After loggin in, the main page loads up.
# Clicking a link
    MyBrowser.FindElementByClass("dialogLink tooltip accordion-override-links").Click
    
End Sub

The last line of code returns an error.

Compound class names not permitted.

I need a different way of locating and clicking that element on the webpage.

I used the developer tool and these are what I see

Copy Element  
<a href="#" class="dialogLink tooltip accordion-override-links"  
rel="taxType=salesAndUseTax">  
File/Pay Retail Sales and Use Tax</a>  
Copy Selector  
#homePageAccordionMenu > div:nth-child(2) > p:nth-> child(1) > span > a  
Copy Xpath  
//*[@id="homePageAccordionMenu"]/div[1]/p[1]/span/a

How could I select this element?

vba


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source