Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SyntaxError: Unexpected token '=' #7

Closed
sstanley-yelnatss opened this issue May 28, 2020 · 5 comments
Closed

SyntaxError: Unexpected token '=' #7

sstanley-yelnatss opened this issue May 28, 2020 · 5 comments

Comments

@sstanley-yelnatss
Copy link

sstanley-yelnatss commented May 28, 2020

Just downloaded it but now when I run my program I keep getting this error selenium.common.exceptions.WebDriverException: Message: unknown error: Runtime.evaluate threw exception: SyntaxError: Unexpected token '='

I changed it back to normal selenium chromedriver and it worked fine so I am not sure what's going wrong as it does not seem to be my code

Here is the full error message
Selenium patched. Safe to import Chrome / ChromeOptions
Selenium patched. Safe to import Chrome / ChromeOptions
Traceback (most recent call last):
File "botc.pyx", line 89, in
order(keys)
File "botc.pyx", line 21, in wrapper
result = method(args, **kw)
File "botc.pyx", line 40, in order
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, '//
[contains(text(), "Large")]'))).click()
File "/usr/local/lib/python3.8/dist-packages/selenium-3.141.0-py3.8.egg/selenium/webdriver/remote/webelement.py", line 80, in click
self._execute(Command.CLICK_ELEMENT)
File "/usr/local/lib/python3.8/dist-packages/selenium-3.141.0-py3.8.egg/selenium/webdriver/remote/webelement.py", line 633, in _execute
return self._parent.execute(command, params)
File "/usr/local/lib/python3.8/dist-packages/selenium-3.141.0-py3.8.egg/selenium/webdriver/remote/webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "/usr/local/lib/python3.8/dist-packages/selenium-3.141.0-py3.8.egg/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Runtime.evaluate threw exception: SyntaxError: Unexpected token '='
(Session info: chrome=81.0.4044.92)

@ultrafunkamsterdam
Copy link
Owner

Hi Stanley,

Unfortunately, the stacktrace does not show any file belonging to this package. can you please share your code? Please also mind the order of imports. Importing selenium components after this this package may cause configuration changes.

@sstanley-yelnatss
Copy link
Author

Yeah.

`from config import keys
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
import time
from undetected_chromedriver import Chrome

def timeme(method):
def wrapper(*args, **kw):
startTime = int(round(time.time() * 1000))
result = method(*args, **kw)
endTime = int(round(time.time() * 1000))
print("Execution Time: {}".format((endTime - startTime)/1000))
return result
return wrapper

@TImeME
def order(k):

driver.get(k['product_url'])



driver.find_element_by_xpath('//*[contains(.,"Jacket")][following-sibling::div[contains(.,"Black")]]/a').click()



WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, '//*[contains(text(), "L")]'))).click()


driver.find_element_by_xpath('//input[@value="add to cart"]').click()


driver.find_element_by_xpath('/html/body/div[2]/div/div[1]/div/a[2]').click()


driver.find_element_by_xpath('//*[@id="order_billing_name"]').send_keys(k["name"])


driver.find_element_by_xpath('//*[@id="order_email"]').send_keys(k["email"])


driver.find_element_by_xpath('//*[@id="order_tel"]').send_keys(k["phone_number"])


driver.find_element_by_xpath('//*[@name="order[billing_address]"]').send_keys(k["address"])


driver.find_element_by_xpath('//*[@id="order_billing_zip"]').send_keys(k["zip"])


driver.find_element_by_xpath('/html/body/div[2]/div[1]/form/div[2]/div[2]/fieldset/div[1]/div[2]/input').send_keys(k["card_number"])


driver.find_element_by_xpath('/html/body/div[2]/div[1]/form/div[2]/div[2]/fieldset/div[1]/div[3]/div[1]/select[1]/option[1]').click()


driver.find_element_by_xpath('/html/body/div[2]/div[1]/form/div[2]/div[2]/fieldset/div[1]/div[3]/div[1]/select[2]/option[4]').click()


driver.find_element_by_xpath('/html/body/div[2]/div[1]/form/div[2]/div[1]/fieldset/div[5]/div[3]/select/option[12]').click()


driver.find_element_by_xpath('/html/body/div[2]/div[1]/form/div[2]/div[2]/fieldset/div[1]/div[3]/div[2]/input').send_keys(k["cvv"])



driver.find_element_by_xpath('/html/body/div[2]/div[1]/form/div[2]/div[2]/fieldset/p[2]/label/div/ins').click()

if name == 'main':
driver = Chrome()
order(keys)`

@sstanley-yelnatss
Copy link
Author

I rewrote the program without any selenium imports but the problem is I need either time or seleniums common exceptions to be imported for my program to work and no matter where I add either of these packages before or after the uc chromdriver it returns the same error

@ultrafunkamsterdam
Copy link
Owner

You need to import selenium AFTER this package. See the README -> second or third usage example!

@ultrafunkamsterdam
Copy link
Owner

I rewrote the program without any selenium imports but the problem is I need either time or seleniums common exceptions to be imported for my program to work and no matter where I add either of these packages before or after the uc chromdriver it returns the same error

import undetected_chromedriver as uc
uc.install()  # < important

from selenium.webdriver import Chrome # and all other offical selenium stuff you need

driver = Chrome()
driver.get('https://distilnetworks.com')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants