Salutations,
I'm writing code to scrape a website using Selenium and Excel VBA. The website in question has a menubar in which a menu option is visble to VBA only when hovered (class = "hovered" when the cursor is over the text, class = "" when the cursor is not over the text). Furthermore, while stepping into my code, I'm unable to click the link using Automation or Manually.
Please see code below:
WebsiteURL = "https://navinet.navimedix.com/signed-out/session-expired?
ReturnUrl=/"
driver.Get WebsiteURL
driver.Window.Maximize
driver.FindElementById("LoginPortletUsername").SendKeys (UserName) 'Reads
Username
driver.FindElementById("LoginPortletPassword").SendKeys (Password) 'Reads
password
driver.FindElementById("btnSignInSubmit").Click
Application.Wait (Now + TimeValue("0:00:20"))
driver.FindElementById("mh-workflows-my-health-plans-menu").Click
driver.FindElementById("workflows-menu-plan-aetna").Click
Application.Wait (Now + TimeValue("0:00:10"))
driver.Window.Activate
driver.FindElementById("aetna-eligibility").Click
The code works up until point, however the following options to access the menupath do not work.
Option 1 (Move Cursor & Click)
SetCursorPos 2221, 289
Call SingleClick
With
Private Sub SingleClick()
SetCursorPos 2286, 69 'x and y position for Health Edge search
mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
End Sub
And
Public Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long 'mouse position
Public Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long) 'user environment
Public Const MOUSEEVENTF_LEFTDOWN = &H2
Public Const MOUSEEVENTF_LEFTUP = &H4
Public Const MOUSEEVENTF_RIGHTDOWN As Long = &H8
Public Const MOUSEEVENTF_RIGHTUP As Long = &H10
Option 2 (Move Cursor & Find New Class)
SetCursorPos 2221, 289
driver.FindElementByClass("hovered").Click
Option 3 (Find Object Directly)
driver.FindElementByXPath("//*[@id='vertical-menu']/li[4]/ul/li/a").Click
Option 4 (Use Move To Element Via Menu Path & Click)
Set we = driver.FindElementByXPath("//*[@id='vertical-menu']/li[4]/ul/li/a")
driver.Actions.MoveToElement(driver.FindElementById("aetna-eligibility")).MoveToElement(we).Click.Perform
Any tips or alternatives would help greatly. This has been driving me crazy!