• Content count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About jack_

  • Rank

Profile Information

  • Gender
  • Location
  • Interests
    Programming, Computers, Technology, Mathematics
  1. I am using "Python-3.4.1 32 bit" on "Windows 7 64 bit" machine with "Selenium" using "Firefox 33". I am trying to automate downloading a "CSV" file from a secured website after furnishing the necessary credentials. I have written the required code to navigate to the correct element to initiate the download of the file but I am stuck when Firefox gives the download box (Dialog box title: Opening export.csv, "Open with" and "Save File" options as radio buttons with "OK" and "Cancel" as buttons). I want the file to be downloaded automatically and for that I have tried the following codes without success: from selenium import webdriverfp = webdriver.FirefoxProfile()fp.set_preference("browser.download.manager.showWhenStarting",False)fp.set_preference("browser.download.folderList",2)fp.set_preference("browser.download.dir", "C:UsersarunDownloads")fp.set_preference("browser.download.downloadDir", "C:UsersarunDownloads")fp.set_preference("browser.download.defaultFolder", "C:UsersarunDownloads")fp.set_preference('browser.helperApps.neverAsk.saveToDisk',"text/csv")driver = webdriver.Firefox(fp)driver.get("http://website-url.com") and then click on the button to start the download. But, it still shows the dialog box. I even tried handling it as an alert and tried alert = driver.switch_to_alert()alert.accept() but this always gave an exception of alert not found which led me to the conclusion that it might not be a JavaScript functionality after all but rather a web element. I am giving sufficient delay for the alert box to appear before I try to interact with it using the "alert" object code shown above.What do I do to get this downloaded automatically without the dialog box interaction (the way it's handled in Google Chrome browsers)I think that the server is not assigning the correct MIME type for the file that is being downloaded? The file I am downloading is of type: "text/csv" and in Firefox when the dialog box appears, "Do this automatically for files like this from now on" check box is greyed out.Thanks for your help and timeCheers!
  2. Thanks "thescientist" and "justsomeguy" for your replies (detailed explanation by justsomeguy) I worked on a similar concept "thescientist" and made the automation work. I am posting the code so that you all can use it if you so feel the need for it: from selenium import webdriverfrom selenium.webdriver.common.keys import Keysfrom selenium.webdriver import ActionChainsfrom selenium.webdriver.common.by import Byfrom selenium.webdriver.support.ui import WebDriverWaitimport timedriver = webdriver.Firefox()driver.get("http://website_url.com")element_user_name = driver.find_element_by_id("userid")element_user_name.send_keys("user_name")element_passwd = driver.find_element_by_id("password")element_passwd.send_keys("a_passwd")elem = driver.find_element_by_id("submit")elem.send_keys(Keys.RETURN)driver.implicitly_wait(60) # implicitly waitmenu = driver.find_element_by_id("ROOT/Favorites and Dashboards")driver.implicitly_wait(20)time.sleep(60)ActionChains(driver).move_to_element(menu).click(menu).perform() # clickprint('Finished running the scriptnn')
  3. davej, I had already referred to "selenium" documentation (for Python) and found some ways to automate my project. I have sort of navigated to the webpage and am able to interact with the different elements. I would however, very much like to see some other alternative approaches to this problem. Thanks for your suggestion
  4. I am doing a project in which I have to automatically download a file from a secured website by providing a username and password for which I am using "Selenium" with "Python 3.4.1" in Windows 7 x86_64 environment. The website is written using "JavaScript". And I don't know JavaScript.After going through the code for the webpage, so far, I have done this in Python in conjunction with Selenium webdriver: Code: from selenium import webdriverfrom selenium.webdriver.common.keys import Keysdriver = webdriver.Firefox()driver.get("http://www.website_name.com") element_user_name = driver.find_element_by_id("userid")element_user_name.send_keys("user_name")element_passwd = driver.find_element_by_id("password")element_passwd.send_keys("some_passwd")elem = driver.find_element_by_id("submit")elem.send_keys(Keys.RETURN) After this code snippet, I am successfully directed to the home screen of the website. But now, the problem arises. The code of the website contains JavaScript functions which do not contain the codes of the elements on the page which I want to manipulate. The main page contains code for user authentication, invalidate client and the likes of it.But when I right click on an element ("Inspect element") on the Home page, I get to see their respective codes in a separate window (in Firefox 32).The source code of the element which I want to use "Favorites and Dashboards" is present as: Code:<!DOCTYPE html><html id="ext-gen3" class=" ext-strict x-viewport" decorator="blank" webdriver="true"><head></head><body id="ext-gen4" class="ext-gecko3 cwc-view x-border-layout-ct" onload="cwc.getFrameworkWindow()"><div id="cwc_header" class=" masthead x-border-panel" style="left: 0px; top: 0px; width: 1366px; height: 27px;"></div><div id="cwcNavPanel" class=" x-panel cwc-navPanel x-border-panel" style="width: 220px; left: 0px; top: 56px;"><div id="ext-gen17" class="x-panel-bwrap"><div id="ext-gen18" class="x-panel-tbar x-panel-tbar-noheader" style="width: 220px;"></div><div id="ext-gen19" class="x-panel-body x-panel-body-noheader" style="width: 220px; height: 323px;"><div id="cwcAccordionNav" class=" x-panel x-panel-noborder" style="width: 218px;"><div id="ext-gen48" class="x-panel-bwrap"><div id="ext-gen49" class="x-panel-body x-panel-body-noheader x-panel-body-noborder" style="overflow: auto; width: 218px; height: 321px;" role="navigation"><div id="ROOT/Favorites and Dashboards" class="x-panel x-panel-noborder x-tree" style="width: auto;"><div id="ext-gen76" class="x-panel-header x-panel-header-noborder x-unselectable x-accordion-hd" style="cursor: pointer;" tabindex="0" role="tab" aria-expanded="true"></div><div id="ext-gen77" class="x-panel-bwrap" style="display: block; visibility: visible; position: static; left: 0px; top: 0px; z-index: auto;"><div id="ext-gen78" class="x-panel-body x-panel-body-noborder" style="width: auto; height: auto;"><ul id="ext-gen79" class="x-tree-root-ct x-tree-arrows" role="group"><div class="x-tree-root-node"><li class="x-tree-node"></li><li class="x-tree-node"></li><li class="x-tree-node"></li><li class="x-tree-node"></li><li class="x-tree-node"></li><li class="x-tree-node"></li><li id="ext-gen447" class="x-tree-node"><div id="ROOT/Favorites and Dashboards/6" class="x-tree-node-el x-unselectable x-tree-node-collapsed" unselectable="on" ext:tree-node-id="ROOT/Favorites and Dashboards/6"><span class="x-tree-node-indent"></span><img id="ext-gen94" class="x-tree-ec-icon x-tree-elbow-plus" src="/sm/default/s.gif" alt=""></img><img class="x-tree-node-icon cwc-tree-noIcon-node" unselectable="on" src="/sm/default/s.gif" alt=""></img><a id="ext-gen95" class="x-tree-node-anchor" tabindex="0" href="" role="treeitem" hidefocus="on" aria-expanded="false"> In this snippet, I want to click on "Favorites and Dashboards". Why is this code not present in the main page and how do i come to this code?Thanks for your help!