I am writing a script by using selenium. My problem is when the chrome has been automatically updated, my script is not working. So, my solution is learning the web chrome version (not driver) at the beginning and run the related chrome driver. So on my desktop I will keep all versions and run the correct one. But I could not find a solution to get the version of chrome. I will kindly appreciate the helps! Thanks in advance!
-
Maybe call 'google-chrome --version' from python? call like thisshimo– shimo2020-01-10 12:29:36 +00:00Commented Jan 10, 2020 at 12:29
-
I think it will be solution but anyway I could not find what exactly should I writeOguzhan Rmre Akdag– Oguzhan Rmre Akdag2020-01-10 12:51:54 +00:00Commented Jan 10, 2020 at 12:51
-
If you are on windows, try this (stackoverflow.com/questions/50880917/…). Worked for me.Satish Michael– Satish Michael2020-01-10 12:58:19 +00:00Commented Jan 10, 2020 at 12:58
-
I should get it via Python, using cmd is a manual step for me. Thank youOguzhan Rmre Akdag– Oguzhan Rmre Akdag2020-01-10 13:03:07 +00:00Commented Jan 10, 2020 at 13:03
-
See my answer belowSatish Michael– Satish Michael2020-01-10 13:13:39 +00:00Commented Jan 10, 2020 at 13:13
Add a comment
|
2 Answers
Try this.
import subprocess
output = subprocess.check_output(
r'wmic datafile where name="C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe" get Version /value',
shell=True
)
print(output.decode('utf-8').strip())
output
Version=79.0.3945.117
3 Comments
Oguzhan Rmre Akdag
I had missed "print(output.decode('utf-8').strip())" . You are a hero, thanks a lot:)
undetected Selenium
@Satish Seems you mastered subprocess module :)
ali reza
thanks a lot man ;XX i wrote code: cmd_args = [rf'wmic datafile where name="{chrome_path}".format() get Version /value'] subprocess.Popen(cmd_args, cwd='C:\\Windows\\SysWOW64\\wbem') but didn't work. and for you worked good.
import random
def generate_different_numbers():
return random.sample(range(10), 6)
previous_sequence = []
previous_output = []
RED = "\033[91m"
RESET = "\033[0m"
while True:
input_sequence = input("Enter your 10 numbers separated by commas or spaces: ")
input_sequence = [num.strip() for num in input_sequence.replace(',', ' ').split()]
if len(input_sequence) < 10:
print(RED + "Please enter 10 digits properly." + RESET)
continue
invalid_input = False
for num in input_sequence:
if not num.isdigit() or len(num) > 1:
invalid_input = True
break
if invalid_input:
print(RED + "Color trading does not have tow digits number." + RESET)
continue
input_sequence = [int(num) for num in input_sequence]
if input_sequence != previous_sequence:
output_numbers = generate_different_numbers()
print("Next 6 different numbers:", output_numbers)
previous_sequence = input_sequence
previous_output = output_numbers
else:
if not previous_output:
print("Next 6 different numbers:", generate_different_numbers())
else:
print("Output remains unchanged as last time:", previous_output)
# Print "Created by Unlivingfoil" after every output
print(" ")
print(".........Created by Unlivingfoil.........")
print(" ")6189
1 Comment
Community
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.