Skip to content

Instantly share code, notes, and snippets.

@bbchriscesar
Created January 3, 2020 00:01
Show Gist options
  • Select an option

  • Save bbchriscesar/8997dcd9a5e67ae105ccccf675ce37c8 to your computer and use it in GitHub Desktop.

Select an option

Save bbchriscesar/8997dcd9a5e67ae105ccccf675ce37c8 to your computer and use it in GitHub Desktop.
from selenium import webdriver
import time
import pytest
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import os
@pytest.mark.parametrize("language, profile, profDriver", [
("ar,bg,ca,da,de", "Profile_01", "chromedriver1"),
("el,en-AU,en-GB,en-US,es,es-419,et", "Profile_02", "chromedriver2"),
("fi,fil,fr,hi,hr,hu", "Profile_03", "chromedriver3")
]
)
def test_browserSetup(language, profile, profDriver):
options = webdriver.ChromeOptions()
options.add_argument('--start-maximized')
options.add_argument('user-data-dir=/usr/local/google/home/christiannec/.config/google-chrome/' + profile)
driver = webdriver.Chrome(executable_path='/usr/local/google/home/christiannec/IdeaProjects/SaraoScreenshotFramework/Drivers/' + profDriver, options=options)
driver.implicitly_wait(10)
def waitForElementByCSSselector(CSSselector):
wait = WebDriverWait(driver, 60)
element = wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, CSSselector)))
time.sleep(2)
for language in language.split(","):
path = "/usr/local/google/home/christiannec/IdeaProjects/SaraoScreenshotFramework/Screenshots/SampleProject/" + language
if not os.path.exists(path):
os.makedirs(path)
driver.get('https://ds-next-nightly.qa.adz.google.com/aw/productgroups/subdivide?campaignId=181820422&adGroupId=8328705742&ocid=77722702&criterionId=18283950120&__c=1096204064&forwardDebugInfo=true&apex=AWN_AMALGAM%3ATREATMENT&ignoreMccDiversion&__u=7384272760&hl=' + language)
waitForElementByCSSselector("div.scroll-host")
driver.save_screenshot(path + '/' + '001_samplescreenshot.png')
driver.quit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment