Closed fire17 closed 2 years ago
Hi, sorry I have no experience on heroku, but did you google something like selenium in heroku? I found this, may be of help https://stackoverflow.com/questions/42860703/how-to-use-selenium-webdriver-on-heroku
never used heroku, but it seems that the front page does not load. Perhaps try screenshot the page when the exception occured just to see how it's rendered?
not sure if this script works
from selenium.common.exceptions import TimeoutException
from openwa import WhatsAPIDriver
driver = WhatsAPIDriver(client='firefox') # replace this with your setup
try:
print("Waiting for QR")
driver.wait_for_login()
print("Bot started")
except TimeoutException as e:
driver.driver.screenshot('screenshot.png') # save screenshot file to storage
raise e
Regarding https://github.com/open-wa/wa-automate-python/issues/83#issuecomment-899063248
which browser are you using, could you provide your heroku setup?
could you execute driver.execute_script("return navigator.userAgent")
to see the user agent?
SEEMINGLY same as before but I dont think that my issue now was the same as it was before, Pretty sure what solved it the first time was adding
chrome_options.add_argument("--disable-dev-shm-usage")
chrome_options.add_argument("--no-sandbox")
chrome_options.add_argument('--disable-gpu')
I have followed @darkash 's advice and save a screenshot, which said (on a whatsappweb style page) (here's how)
# (on server)
print("!!!!!!!!!!!!!! userAgent", driver.driver.execute_script("return navigator.userAgent"))
print(''' ::: waiting for login ::: ''')
try:
driver.wait_for_login()
except:
driver.screenshot('loginFailed.png') # save screenshot file to storage
print(" ::: ERROR - waiting for login - screenshot saved to loginFailed.png ::: ")#,"\n",e,e.args,"\n")
traceback.print_exc()
# (on local)
heroku ps:copy loginFailed.png -a app-example-prod --output=~/loginFailed_from_heroku.png
Browser Not Supported
we recomend using one of the following : Chrome, Firefox, Edge, Opera, Safari
I've checked the chromedriver installed on heroku through the buildpacks, it said 92.0.4515.107
so now i'm trying it out with
chrome_options.add_argument("--user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36")
hope it works
(just read what you wrote, will try to not set user-agent and print driver.execute_script("return navigator.userAgent") )
got
!!!!!!!!!!!!!! userAgent Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/92.0.4515.131 Safari/537.36
im guessing the HeadlessChrome is the problem, again tried to set the user agent again (didnt work)
now got
!!!!!!!!!!!!!! userAgent Mozilla/5.0
so i will try
chrome_options.add_argument("--user-agent=Chrome/92.0.4515.107")
Now im getting
!!!!!!!!!!!!!! userAgent Chrome/92.0.4515.131
and
Is it possible that the buildpacks for chrome and chromedriver are TOO NEW ? any idea on how to downgrade chrome and chromedriver ? id like to still use some buildpacks to hopefully not fuckup anything else in my setup
Also tried
chrome_options.add_argument("--user-agent=Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36")
and
chrome_options.add_argument("--user-agent=Chrome/89.0.4389.90")
did not work
any suggestions ???
thx
You sure the chrome in heroku is updated? Not the chromedriver but rather the browser executable
I don't think spoofing user-agent will work
I get both chrome and chromedriver there from buildpacks so both should be latest and Ideally the same . . . :/
Maybe I or someone will take a look at this in the future and give better answers, probably to install a specific version of chrome that's compatible with a specific version of chromedriver
Hi There! maybe you can help ..
I suddenly get stuck while waiting for login... Not sure what changed but I get timeout error rasing the timeout doesnt help, still stuck forever then crashes the same
works fine on my machine, all the profile files and other paths are set correctly on server env
if you have any suggestions i would love to try stuff out... for now ill try rolling untill i find something that worked in the past and merge it somefuckinghow (lol)
THX :)