Hover over sub-menu with Selenium

时间:2017-08-30 20:14:26

标签: python selenium

Actions Menu I have been tasked with automating the submission of a form (Company access only) and then exporting the results to excel. My code does click on the 'Actions' menu to activate the drop down list, but from there it does nothing. I need to hover over the Using Selenium, here is a snippet of the code, specifically for the menu I need to: 1. Hover over the "Open with Report Builder" 2. 'Down' arrow twice to 'Export' 3. 'Right' arrow over to the sub-sub-menu 4. 'Down' arrow 3x and 'click' on 'Excel'

plt.savefig('Subj%s_left_LEC_DGCA3.png' % (betaNum+1))

Here is the HTML associated with the 'Actions' Menu

plt.savefig('Subj{}_left_LEC_DGCA3.png'.format(betaNum+1))

I believe this is the HTML for the 'Export' and 'Excel'

Sub Copier()
Dim x As String
Dim z As Integer
x = InputBox("Enter Number of Days in Month")
If x = "" Then
     MsgBox "User Pressed Cancel!" & vbCrLf & _
            "or did not enter a value!", vbOKOnly + vbInformation, _
            "Inputbox Result:"
     z = 10
     Exit Sub
ElseIf CInt(x) = 0 Then
     MsgBox "User Pressed Cancel!" & vbCrLf & _
            "or did not enter a value!", vbOKOnly + vbInformation, _
            "Inputbox Result:"
     z = 10
     Exit Sub
Else: End If
y = CInt(x) - 1
For numtimes = 1 To y
ActiveWorkbook.Sheets("Sheet1").Copy _
after:=ActiveWorkbook.Sheets("Sheet1")
Next

DoDays

End Sub



Private Sub COPY_NUMBER_Click()
COPY_NUMBER.BackColor = 12713921
Copier
' DoDays
COPY_NUMBER.BackColor = 12500670
COPY_NUMBER.Enabled = False
End Sub

1 个答案:

答案 0 :(得分:0)

尝试使用以下代码 -

actions_menu = driver.find_element_by_xpath("//*[@alt='Open Menu']").click()
export = driver.find_element_by_xpath("//*[@text='Export']")
excel = driver.find_element_by_xpath("//*[@text='Excel']")
actions = ActionChains(driver)
actions.move_to_element(export).click(excel).perform()