3

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!

5
  • Maybe call 'google-chrome --version' from python? call like this Commented Jan 10, 2020 at 12:29
  • I think it will be solution but anyway I could not find what exactly should I write Commented Jan 10, 2020 at 12:51
  • If you are on windows, try this (stackoverflow.com/questions/50880917/…). Worked for me. Commented Jan 10, 2020 at 12:58
  • I should get it via Python, using cmd is a manual step for me. Thank you Commented Jan 10, 2020 at 13:03
  • See my answer below Commented Jan 10, 2020 at 13:13

2 Answers 2

8

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
Sign up to request clarification or add additional context in comments.

3 Comments

I had missed "print(output.decode('utf-8').strip())" . You are a hero, thanks a lot:)
@Satish Seems you mastered subprocess module :)
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.
0
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

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.