selenium screenshot python user agent

Solutions on MaxInterview for selenium screenshot python user agent by the best coders in the world

showing results for - "selenium screenshot python user agent"
Martín
15 Jul 2019
1from selenium import webdriver
2
3user_agent = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.50 Safari/537.36'
4
5options = webdriver.ChromeOptions()
6# specify headless mode
7options.add_argument('headless')
8# specify the desired user agent
9options.add_argument(f'user-agent={user_agent}')
10driver = webdriver.Chrome(chrome_options=options)
11
12# user-agent is now set
13
Emma
10 Jul 2019
1#I want each time chrome opens it will automatically run with a useragent taken from the txt file in order from line 1 -> line 10 . I'm a new member, someone please help me
2
3from selenium import webdriver
4from selenium.webdriver.chrome.options import Options
5import time
6
7key="something"
8while key != "q":    
9 username_list = list()
10 with open("a.txt") as file:
11     for line in file:
12        agent = line.split(':')
13        username_list.append((agent))  
14 options = Options()
15 options.add_argument(f'user-agent={agent[0]}')
16 driver = webdriver.Chrome(chrome_options=options, executable_path=r'C:\Program 
17Files (x86)\chromedriver.exe')
18 driver.get("https://www.deviceinfo.me/")
19 time.sleep(5) # Let the user actually see something!
20 driver.quit()
21key=str(input())