Skip to content

Instantly share code, notes, and snippets.

@bbchriscesar
Last active January 8, 2021 18:53
Show Gist options
  • Save bbchriscesar/7fecb54f4ab7d7b6eb43f5bef6bb715d to your computer and use it in GitHub Desktop.
Save bbchriscesar/7fecb54f4ab7d7b6eb43f5bef6bb715d to your computer and use it in GitHub Desktop.
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import os.path
import time
driver = webdriver.Firefox(executable_path=r'/root/PlayGround/geckodriver')
locales = ['en', 'ja', 'de', 'no']
for locale in locales:
path = '/root/PythonOutput/' + locale
if not os.path.exists(path):
os.makedirs(path)
driver.get('https://www.google.com/?hl=' + locale)
time.sleep(1)
driver.get_screenshot_as_file(path + '/' + 'google3.png')
time.sleep(1)
searchbox = driver.find_element_by_xpath("//input[@id='lst-ib']")
searchbox.send_keys('Whos your daddy')
searchbox.submit()
time.sleep(2)
driver.get_screenshot_as_file(path + '/' + 'searchresult3.png')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment