-3

I am creating a script that should ask for a browser of your choice and then use it:

i am fairly new to selenium and webdriver

#-*- coding:utf-8 -*-
from selenium import webdriver
import time
import tomorrow import threads

def startBrowser(name):
    """
    browsers,"firefox"、"chrome"、"ie"、"phantomjs"
    """
    try:
        if name == "firefox" or name == "Firefox" or name == "ff":
            print("start browser name :Firefox")
            driver = webdriver.Firefox()
            return driver
        elif name == "chrome" or name == "Chrome":
            print("start browser name :Chrome")
            driver = webdriver.Chrome()
            return driver
        elif name == "ie" or name == "Ie":
            print("start browser name :Ie")
            driver = webdriver.Ie()
            return driver
        elif name == "phantomjs" or name == "Phantomjs":
            print("start browser name :phantomjs")
            driver = webdriver.PhantomJS()
            return driver
        else:
            print("Not found this browser,You can use ‘firefox‘, ‘chrome‘, ‘ie‘ or ‘phantomjs‘")
    except Exception as msg:
        print("message: %s" % str(msg))

@threads(5)
def run_case(name):
    driver = startBrowser(name)
    driver.get("https://news.ycombinator.com/")
    time.sleep(3)
    print(driver.title)
    driver.close()
    driver.quit()

if __name__ == "__main__":
    names = ["chrome", "ff", "ie"]
    for i in names:
        run_case(i)

the error:

Traceback (most recent call last):
  File "main.py", line 4, in <module>
    from tomorrow import threads
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/tomorrow/__init__.py", line 1, in <module>
    from .tomorrow import threads
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/tomorrow/tomorrow.py", line 20
    def async(n, base_type, timeout=None):
        ^
SyntaxError: invalid syntax

i dont know what the problem is. can somebody please help me, because i am very confused.

  • It should say `from tomorrow import threads`, not `import tomorrow import threads`. This is probably a simple typo, but I added the best duplicate link I could find just in case. Please read [ask] and **do not edit the question again for a different problem**. Keep in mind that this is **not a discussion forum**, and the purpose of posts here is **not** to help you get your code working, but for *you* to help *us* to build a Q&A library. – Karl Knechtel Oct 12 '22 at 02:26
  • The first question you asked was also about a typo (if you have basic knowledge) or a common duplicate (if you need to have it explained, which many people do). As well as [ask], please read [How to debug small programs](https://ericlippert.com/2014/03/05/how-to-debug-small-programs/) and [How much research effort is expected of Stack Overflow users?](https://meta.stackoverflow.com/questions/261592). – Karl Knechtel Oct 12 '22 at 02:29
  • i am sorry it was a typo and i corrected it to what i meant to type this is what i had for the first question but i edited it because it showed a diffrent bug but that was my bad anyways here is the real question @KarlKnechtel – Tyler The Creator Oct 12 '22 at 02:54
  • What part of **do not edit the question again for a different problem** was unclear? – Karl Knechtel Oct 12 '22 at 02:59
  • my bad, im sorry – Tyler The Creator Oct 12 '22 at 03:05

1 Answers1

0

str.lower is a function, so SearchEngine = input("What Search Engine do you want to use? ").lower will set SearchEngine to the function lower, not the result of lower(). Replacing lower with lower() will fix the problem.

David D
  • 11
  • 2
  • i got rid of that code because there were to many bugs with it i would appreciate if you would check out the edit i made and thank you for your help – Tyler The Creator Oct 12 '22 at 02:24