1

Currently I am using the selenium webdriver to automate a reporting pull that occurs daily.

Basically, I am looking to repeat this code about 30 times for each report. In addition I need to "press" the down key an additional time each time the code is run. I hope I am giving you guys enough info with this. If not, just ask - as always your help is GREATLY appreciated.

ProgramManagement= browser.find_element_by_partial_link_text('Program Management').send_keys(Keys.ARROW_DOWN, Keys.ENTER)

browser.find_element_by_id("ctl00_PlaceHolderMain_ReportViewer1_HtmlOutputReportResults2_CSVButton_Content").click()
3
  • Its hard to help if we don't know what the problem is. Commented Mar 2, 2016 at 14:28
  • I am not sure how to use a loop to run this bit of code ~30 times. Additionally, I am unsure how to increase number of down key presses on each loop pass. Commented Mar 2, 2016 at 14:29
  • As a sidenote, I recommend trying to avoid using those microsoft generated IDs seeing as they can change between versions Commented Mar 2, 2016 at 14:35

2 Answers 2

1

The amount of "key down"s can be increased by multiplication:

for report in reports:
    for x in range(0, 30):
        browser.find_element_by_partial_link_text('Program Management').send_keys(Keys.ARROW_DOWN * x, Keys.ENTER)
        browser.find_element_by_id("ctl00_PlaceHolderMain_ReportViewer1_HtmlOutputReportResults2_CSVButton_Content").click()

Note the relevant Keys.ARROW_DOWN * x part.

Sign up to request clarification or add additional context in comments.

3 Comments

Ok - this looks like what I need, however I am getting an error: undefined name: 'Reports' Again, I am new so I am not sure what this means
@Yogwhatup the for report in reports: loop is just an example implementation of what you were describing "I am looking to repeat this code about 30 times for each report"..we don't know what you meant by that and improvised.
Works! Thank you for all of the help.
0

If I understand you correctly you want something like

for report in reports:
    for x in range(0, 30):
        ProgramManagement= browser.find_element_by_partial_link_text('Program Management').send_keys(Keys.ARROW_DOWN, Keys.ENTER)
        browser.find_element_by_id("ctl00_PlaceHolderMain_ReportViewer1_HtmlOutputReportResults2_CSVButton_Content").click()

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.