Skip to content

Instantly share code, notes, and snippets.

@typedt
Created August 17, 2014 11:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save typedt/c7255ea51608fe52b85c to your computer and use it in GitHub Desktop.
Save typedt/c7255ea51608fe52b85c to your computer and use it in GitHub Desktop.
Solution to Problem 1 of PythonChallenge.com
#!/usr/bin/env python
s = "g fmnc wms bgblr rpylqjyrc gr zw fylb. rfyrq ufyr amknsrcpq ypc dmp. bmgle gr gl zw fylb gq glcddgagclr ylb rfyr'q ufw rfgq rcvr gq qm jmle. sqgle qrpgle.kyicrpylq() gq pcamkkclbcb. lmu ynnjw ml rfc spj."
def make_rotation(i):
def rotate(x):
if x.isalpha():
shift = i if ord(x) + i < 123 else i - 26
return chr(ord(x) + shift)
else:
return x
return rotate
for i in range(0,26):
print '\nindex:%d' %i
print ''.join( map(make_rotation(i), list(s)) )
@niveditakhoche
Copy link

Hi This is regarding selenium automation I am trying to switch between tabs using window handler could you tell me what am I doing wrong.
[3/14/16, 8:57:09 AM] akhoche: 1. go to Gmail
[3/14/16, 8:57:29 AM] akhoche: 2. open bing.com in next tab
[3/14/16, 8:59:14 AM] akhoche: I am using browser.execute_script('''window.open("http://bings.com","_blank");''')
[3/14/16, 8:59:37 AM] akhoche: to open new tab as Keys.COMMAND +’t’ is not working
[3/14/16, 9:00:49 AM] akhoche: Also, for switching between windows I am trying to use window handler but could not get it work.Could you please let me know what am I doing wrong and what needs to be done thanks.
[3/14/16, 9:01:02 AM] akhoche: browser = self.resource_handler.driver
browser.set_page_load_timeout(60)
browser.implicitly_wait(15)
browser.get("http://google.com")
main_window = browser.current_window_handle
#main_window = browser.getWindowHandle()

    print main_window

    # time.sleep(5)
    # browser.execute_script('''window.open("http://bings.com","_blank");''')
    # time.sleep(2)
    # second_window = browser.current_window_handle
    print browser.title
    #------------------------
    #body = browser.find_element_by_tag_name("body").send_keys(Keys.COMMAND+Keys.TAB)
    browser.execute_script('''window.open("http://bings.com","_blank");''')

    #browser.find_element_by_tag_name("body").send_keys(Keys.COMMAND + Keys.ENTER)


    time.sleep(5)
    print 'new oldtab opened'
    print browser.title
    browser.switch_to_window(main_window)
    print browser.switch_to_window(browser.window_handles[1])
    print 'newtab opened'
    time.sleep(5)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment