from selenium import webdriver
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.support.ui import WebDriverWait
from time import sleep, time, gmtime, strftime
from email.message import EmailMessage
import sys, traceback
import datetime
import time
import smtplib
import os

options = Options()
driver = webdriver.Firefox(options=options)
url = 'https://securesites.oracle.com/lift-for-partners/assets/cloud-solution-specialists-toolkit.html'
driver.get(url)

o=driver.find_element("xpath", '//input[@id="sso_username"]')
o.click()
o.send_keys("cgi.oracle.partner.es@cgi.com")

o=driver.find_element("xpath", '//input[@id="ssopassword"]')
o.click()
o.send_keys("AVTheineken9234")

o=driver.find_element("xpath", '//input[@id="signin_button"]')
o.click()

#Aceptamos las cookies
miframe=driver.find_element("xpath", '//iframe[@class="truste_popframe"]')
driver.switch_to.frame(miframe)
o=driver.find_element("xpath", '//a[@class="call"]')
o.click()

driver.refresh()

miframe=driver.find_element("xpath", '//iframe[@id="iframe-a0caee09-b224-45ca-9c88-57f6750d3ebc"]')
driver.switch_to.frame(miframe)

miframe=driver.find_element("xpath", '//iframe[@id="oce-frame-1"]')
driver.switch_to.frame(miframe)

checkboxes=driver.find_elements("xpath", '//input[@type="checkbox" and not(@title="Click to select or unselect all items") and not(@title="Select Cloud solution specialists decks") and not(@title="Select Cloud Solution Specialists Repository") and not(@title="Select Development") and not(@title="Select Fragments") and not(@title="xxxxx")]')


checkboxes=driver.find_elements("xpath", '//input[@type="checkbox" and not(@title="Click to select or unselect all items")]')

for checkbox in checkboxes:
    titulo = checkbox.get_attribute('title')
    print("Descargando: " + titulo)
    o=driver.find_element("xpath", '//input[@title="' + titulo + '"]')
    o.click()
    time.sleep(2)
    o=driver.find_element("xpath", '//button[@id="ct_action_bulk_download"]')
    o.click()
    time.sleep(2)
    o=driver.find_element("xpath", '//input[@title="' + titulo + '"]')
    o.click()    
    time.sleep(10)
***************************************************************************************************************************
Select Cloud solution specialists decks
Select Cloud Solution Specialists Repository
Select Development
Select Fragments



driver.refresh()


o=driver.find_element("xpath", '//input[@type="checkbox"]')
o=driver.find_element("xpath", '//div[@id="page-wrapper"]')
o=driver.find_element("xpath", '//a[@class="back-to-top-button clear-back-to-top-button"]')

o=driver.find_element("xpath", '//button[@id="ct_action_bulk_download"]')


o=driver.find_element("xpath", '//div[@class="containerview-table-row-content"]')
o.click()





o=driver.find_element("xpath", '//div[@id="osn-main"]')


miframe=driver.find_element("xpath", '//iframe[@id="pop-frame024640618558491167"]')
driver.switch_to.frame(miframe)
o=driver.find_element("xpath", '//a[@class="call"]')
o.click()

o.send_keys(Keys.TAB);


driver.find_elements_by_xpath("//*[contains(text(), 'Zustimmen')]")

***************************************************************************************************************************
driver.save_screenshot(os.getcwd()+"jurjurscreen")