私は、フォームの提出を自動化して(企業アクセスのみ)、結果をExcelにエクスポートすることを任されています。私のコードはドロップダウンリストを有効にするために 'Actions'メニューをクリックしますが、そこからは何もしません。私はSeleniumの上にカーソルを置く必要があります。具体的には、メニューのコードのスニペットです。 1. "Open with Report Builder" 2. '下へ'矢印を2回押して 'エクスポート' サブサブメニューに 4.「下向き」矢印3回以上の矢印と「エクセル」は、ここで Seleniumでサブメニューに移動
elem4 = driver.find_element_by_id("m_sqlRsWebPart_RSWebPartToolbar_ctl00_RptControls_RSActionMenu_ctl01_t")
elem4.click()
actions = ActionChains(driver)
actions.move_to_element(elem4)
actions.perform()
elem4.send_keys(Keys.DOWN)
elem4.send_keys(Keys.DOWN)
elem4.send_keys(Keys.RIGHT)
elem4.send_keys(Keys.DOWN)
elem4.send_keys(Keys.DOWN)
elem4.send_keys(Keys.DOWN)
elem4.click()
は、[アクション]メニューに関連付けられたHTMLでに「クリック」3.「正しい」
<div id="m_sqlRsWebPart_RSWebPartToolbar_ctl00_RptControls_RSActionMenu_ctl01_t" class="ms-menubuttoninactivehover ms-displayBlock" title="Open Menu" onmouseover="MMU_PopMenuIfShowing(this);MMU_EcbTableMouseOverOut(this, true)" hoveractive="ms-menubuttonactivehover ms-rteThemeBackColor-3-1 ms-displayBlock" hoverinactive="ms-menubuttoninactivehover ms-displayBlock" onclick="if (document.getElementById('m_sqlRsWebPart_RSWebPartToolbar_ctl00_RptControls_RSActionMenu_ctl00').childNodes.length == 0) { MMU_CallbackPreMenuOpen('m_sqlRsWebPart_RSWebPartToolbar_ctl00_RptControls_RSActionMenu_ctl00', 'm_sqlRsWebPart_RSWebPartToolbar_ctl00_RptControls_RSActionMenu_ctl01', 'WebForm_DoCallback(\'m_sqlRsWebPart$RSWebPartToolbar$ctl00$RptControls$RSActionMenu$ctl01\',\'enabled\',MMU_CallbackHandler,\'__CALLBACKCONTEXT__\',MMU_CallbackErrHandler,true)', 60000, 'The request for menu items from the server has timed out.', event); } CoreInvoke('MMU_Open',byid('m_sqlRsWebPart_RSWebPartToolbar_ctl00_RptControls_RSActionMenu_ctl00'), MMU_GetMenuFromClientId('m_sqlRsWebPart_RSWebPartToolbar_ctl00_RptControls_RSActionMenu_ctl01'),event,true, null, 300); return false;" foa="MMU_GetMenuFromClientId('m_sqlRsWebPart_RSWebPartToolbar_ctl00_RptControls_RSActionMenu_ctl01')" oncontextmenu="ClkElmt(this); return false;" style="white-space:nowrap"><a class="ms-menu-a" id="m_sqlRsWebPart_RSWebPartToolbar_ctl00_RptControls_RSActionMenu_ctl01" href="javascript:;" title="Open Menu" style="cursor:pointer;white-space:nowrap;" onfocus="MMU_EcbLinkOnFocusBlur(byid('m_sqlRsWebPart_RSWebPartToolbar_ctl00_RptControls_RSActionMenu_ctl00'), this, true);" onkeydown="MMU_EcbLinkOnKeyDown(byid('m_sqlRsWebPart_RSWebPartToolbar_ctl00_RptControls_RSActionMenu_ctl00'), MMU_GetMenuFromClientId('m_sqlRsWebPart_RSWebPartToolbar_ctl00_RptControls_RSActionMenu_ctl01'), event);" onclick="if (document.getElementById('m_sqlRsWebPart_RSWebPartToolbar_ctl00_RptControls_RSActionMenu_ctl00').childNodes.length == 0) { MMU_CallbackPreMenuOpen('m_sqlRsWebPart_RSWebPartToolbar_ctl00_RptControls_RSActionMenu_ctl00', 'm_sqlRsWebPart_RSWebPartToolbar_ctl00_RptControls_RSActionMenu_ctl01', 'WebForm_DoCallback(\'m_sqlRsWebPart$RSWebPartToolbar$ctl00$RptControls$RSActionMenu$ctl01\',\'enabled\',MMU_CallbackHandler,\'__CALLBACKCONTEXT__\',MMU_CallbackErrHandler,true)', 60000, 'The request for menu items from the server has timed out.', event); } CoreInvoke('MMU_Open',byid('m_sqlRsWebPart_RSWebPartToolbar_ctl00_RptControls_RSActionMenu_ctl00'), MMU_GetMenuFromClientId('m_sqlRsWebPart_RSWebPartToolbar_ctl00_RptControls_RSActionMenu_ctl01'),event,true, null, 300); return false;" oncontextmenu="ClkElmt(this); return false;" menutokenvalues="" serverclientid="m_sqlRsWebPart_RSWebPartToolbar_ctl00_RptControls_RSActionMenu_ctl01" callbackinprogress="" menuitemsdisabled="" menuitemshidden="" menuitemschecked=""><span class="sqlrv-ActionMenuText sqlrv-ToolBarMenuCell">Actions</span><img src="/_layouts/images/blank.gif" style="border:0px" alt="Use SHIFT+ENTER to open the menu (new window)."></a><img class="ms-viewselector-arrow" src="/_layouts/images/menudark.gif" alt="Open Menu"></div>
「エクスポート」と「Excel」のHTMLと思われます
<ie:menuitem id="m_sqlRsWebPart_RSWebPartToolbar_ctl00_RptControls_RSActionMenu_Export" type="submenu" text="Export" callbackitem="true"><ie:menuitem id="m_sqlRsWebPart_RSWebPartToolbar_ctl00_RptControls_RSActionMenu_Export_Label" type="label" menugroupid="2147483647" enabled="true" checked="false"></ie:menuitem><ie:menuitem id="m_sqlRsWebPart_RSWebPartToolbar_ctl00_RptControls_RSActionMenu_XML" type="option" onmenuclick="$find("m_sqlRsWebPart_ctl00_ReportViewer").exportReport("XML");" text="XML file with report data" callbackitem="true" menugroupid="2147483647" enabled="true" checked="false" onmenuclick_original="$find("m_sqlRsWebPart_ctl00_ReportViewer").exportReport("XML");" text_original="XML file with report data" valorig="
"></ie:menuitem>
<ie:menuitem id="m_sqlRsWebPart_RSWebPartToolbar_ctl00_RptControls_RSActionMenu_CSV" type="option" onmenuclick="$find("m_sqlRsWebPart_ctl00_ReportViewer").exportReport("CSV");" text="CSV (comma delimited)" callbackitem="true" menugroupid="2147483647" enabled="true" checked="false" onmenuclick_original="$find("m_sqlRsWebPart_ctl00_ReportViewer").exportReport("CSV");" text_original="CSV (comma delimited)" valorig="
"></ie:menuitem>
<ie:menuitem id="m_sqlRsWebPart_RSWebPartToolbar_ctl00_RptControls_RSActionMenu_PDF" type="option" onmenuclick="$find("m_sqlRsWebPart_ctl00_ReportViewer").exportReport("PDF");" text="PDF" callbackitem="true" menugroupid="2147483647" enabled="true" checked="false" onmenuclick_original="$find("m_sqlRsWebPart_ctl00_ReportViewer").exportReport("PDF");" text_original="PDF" valorig="
"></ie:menuitem>
<ie:menuitem id="m_sqlRsWebPart_RSWebPartToolbar_ctl00_RptControls_RSActionMenu_EXCELOPENXML" type="option" onmenuclick="$find("m_sqlRsWebPart_ctl00_ReportViewer").exportReport("EXCELOPENXML");" text="Excel" callbackitem="true" menugroupid="2147483647" enabled="true" checked="false" onmenuclick_original="$find("m_sqlRsWebPart_ctl00_ReportViewer").exportReport("EXCELOPENXML");" text_original="Excel" valorig="
"></ie:menuitem>
<ie:menuitem id="m_sqlRsWebPart_RSWebPartToolbar_ctl00_RptControls_RSActionMenu_IMAGE" type="option" onmenuclick="$find("m_sqlRsWebPart_ctl00_ReportViewer").exportReport("IMAGE");" text="TIFF file" callbackitem="true" menugroupid="2147483647" enabled="true" checked="false" onmenuclick_original="$find("m_sqlRsWebPart_ctl00_ReportViewer").exportReport("IMAGE");" text_original="TIFF file" valorig="
"></ie:menuitem>
<ie:menuitem id="m_sqlRsWebPart_RSWebPartToolbar_ctl00_RptControls_RSActionMenu_WORDOPENXML" type="option" onmenuclick="$find("m_sqlRsWebPart_ctl00_ReportViewer").exportReport("WORDOPENXML");" text="Word" callbackitem="true" menugroupid="2147483647" enabled="true" checked="false" onmenuclick_original="$find("m_sqlRsWebPart_ctl00_ReportViewer").exportReport("WORDOPENXML");" text_original="Word" valorig="
"></ie:menuitem>
<ie:menuitem id="m_sqlRsWebPart_RSWebPartToolbar_ctl00_RptControls_RSActionMenu_MHTML" type="option" onmenuclick="$find("m_sqlRsWebPart_ctl00_ReportViewer").exportReport("MHTML");" text="MHTML (web archive)" callbackitem="true" menugroupid="2147483647" enabled="true" checked="false" onmenuclick_original="$find("m_sqlRsWebPart_ctl00_ReportViewer").exportReport("MHTML");" text_original="MHTML (web archive)" valorig="
"></ie:menuitem>
</ie:menuitem>
をコード - 以下を試してみてください? – Andersson
私は質問を更新しました。サブメニューを右クリックすると「Inspect」オプションは利用できませんので、このHTMLが「エクスポート」オプションに関連付けられていると仮定しなければなりませんでした。 –