I am using Selenium with Python to download certain files from a website. I am trying to access a option called "View all products >>". From there, you could select the kind of file(csv, xlsx) and then you should download it easily. My problem is that I cannot access that "View all products" area. I've tried in so many ways. I'll attach my code and a screenshot with the structure of website. I cannot post entire HTML because it is a website restrictive only to it's paid users.
1 and 2. (Here "View All Products" appears twice):
<a class="yui3-c-reportdashboardwidget-reportLink" href="./embedded.html?showGDLogo=false#project=/gdc/projects/e05jwlnny6rlxyt5ib9r6479279crrq8&dashboard=/gdc/md/e05jwlnny6rlxyt5ib9r6479279crrq8/obj/4817&tab=8473392139f7&s=/gdc/projects/e05jwlnny6rlxyt5ib9r6479279crrq8|analysisPage|head|/gdc/md/e05jwlnny6rlxyt5ib9r6479279crrq8/obj/3630" title="Headline - View All Products Link" target="_self">Headline - View All Products Link</a>
3 and 4. (Here "View All Products" appears twice):
<span class="yui3-c-reportdashboardwidget-reportLabel" title="Headline - View All Products Link">Headline - View All Products Link</span>
5:
<div class="number" style="font-size: 16px; color: rgb(0, 61, 76);" id="yui_3_14_1_1_1540109592048_72886"> View all products >></div>
The link that I want to handle is number "5", because I think that is the one I need to click(), so that I can download the report afterwards.
My code for this part:
View All Products Button
#product_button = driver.find_elements_by_xpath("//div[@class='c-oneNumberReport yui3-widget yui3-c-onenumberreport yui3-c-onenumberreport-content yui3-widget-content-expanded drillable']")[-1]
#product_button = driver.find_element_by_xpath(("//div[text()='View all products >>']"))
product_button = driver.find_elements_by_xpath("//a[@class='ember-view reportInfoPanelHandle point-to-top']")[-3]
product_button.click()
#product_button.send_keys(Keys.ENTER)
#####actions = ActionChains(driver)
#actions.move_to_element(product_button).send_keys(Keys.ENTER)
###########actions.move_to_element(product_button)
###########actions.click()
#actions.sendKeys(Keys.Return);
#actions.build().perform()
Update::::
Here is the HTML for "Download As..":
<span class="button-text"><script id="metamorph-39-start" type="text/x-placeholder"></script>Download as...<script id="metamorph-39-end" type="text/x-placeholder"></script></span>
HTML for "CSV ( raw data)":
<ul id="ember2849" class="ember-view reportExportMenu gdc-menu-simple" style="position: absolute; top: 106px; left: 15px; z-index: 3005;"><li id="ember2850" class="ember-view reportExportMenuItem">
<a data-ember-action="17"><script id="metamorph-47-start" type="text/x-placeholder"></script>PDF (Portrait)<script id="metamorph-47-end" type="text/x-placeholder"></script></a>
</li><li id="ember2851" class="ember-view reportExportMenuItem">
<a data-ember-action="18"><script id="metamorph-48-start" type="text/x-placeholder"></script>PDF (Landscape)<script id="metamorph-48-end" type="text/x-placeholder"></script></a>
</li><li id="ember2852" class="ember-view reportExportMenuItem">
<a data-ember-action="19"><script id="metamorph-49-start" type="text/x-placeholder"></script>XLSX...<script id="metamorph-49-end" type="text/x-placeholder"></script></a>
</li><li id="ember2853" class="ember-view reportExportMenuItem">
<a data-ember-action="20"><script id="metamorph-50-start" type="text/x-placeholder"></script>CSV (formatted)<script id="metamorph-50-end" type="text/x-placeholder"></script></a>
</li><li id="ember2854" class="ember-view reportExportMenuItem">
<a data-ember-action="21"><script id="metamorph-51-start" type="text/x-placeholder"></script>CSV (raw data)<script id="metamorph-51-end" type="text/x-placeholder"></script></a>
</li></ul>