0

I am trying to login to my account on bet365.com using selenium python. I know that the sites detects selenium and most people usually run into issues. but i didnt get any of the common issues. The sites loads well but when I try to input my correct login details. It says Login details not recognized.

This is my code:

        self.driver.get('https://www.bet365.com')
        
        # Waits until page is fully loaded
        WebDriverWait(self.driver, 20).until(lambda x: 'Log In' in self.driver.page_source)

        login_frame = self.wait(By.CLASS_NAME, 'hm-MainHeaderRHSLoggedOutWide_Login ', time=70)
       
        # Function that clicks the login button
        self.doAction(login_frame)
       
        # Function that waits until the login popup shows
        username = self.wait(By.CLASS_NAME, 'lms-StandardLogin_Username ', time=5)
        username.clear()
        username.send_keys('username') # my username

        password = self.driver.find_element_by_class_name('lms-StandardLogin_Password ')
        password.clear() 
        password.send_keys('password') # my password

        password.send_keys(Keys.RETURN)

is the issue from the site or is the site just saying that because i am using selenium. If i login normally it works fine. Please any swift help will be appreciated

Demaxl
  • 57
  • 2
  • 10

3 Answers3

0

Try to use enter key instead of pass return from password textbox. Same happened to me. Perhaps it would work

from selenium.webdriver.common.keys import Keys
self.driver.find_element_by_class_name("class_name").sendKeys(Keys.ENTER);

Talal Siddiqui
  • 106
  • 1
  • 7
  • It didnt work. I dont think the problem is related to that because even when i click the login button it still says login details recognised – Demaxl Oct 24 '21 at 10:45
  • Then the issue must be with the cookies. You have to check the cookies while logging in the browser and then copy those cookies. check this link "https://pretagteam.com/question/how-to-save-login-data-to-be-recognized-for-python-selenium-webdriver" – Talal Siddiqui Oct 24 '21 at 12:11
  • That sounds like a good idea but the problem is that I havent been able to login once using selenium. Is there a way I can manually export the cookies? I mean I will manually login that copy the cookies and paste it into selenium? – Demaxl Oct 24 '21 at 13:53
  • Please check the link I provided in the last comment. It has a solution in it with code to how to copy, store and use cookies using chromedriver. A library name ```pickle``` – Talal Siddiqui Oct 25 '21 at 05:56
0

It is almost certainly the website prohibiting your code.

bet.365 is a very popular website that definitely incorporates anti-webscraping and bot detection.

Not to mention is also against their terms of service:

https://help.bet365.com/en/terms-and-conditions

If you are still adament you can check out the thread below for work arounds:

Can a website detect when you are using Selenium with chromedriver?

0

First off all, change your chromedriver compilation using this link

https://stackoverflow.com/a/52108199/5393597

After, use this script:

driver.get(URL_BET_THREE_SIX_FIVE)

# Check loading page
Wait(driver, 60).until_not(EC.presence_of_element_located((By.CLASS_NAME, "bl-Preloader_SpinnerContainer ")))

# Close popup if exist
try:
    popup = driver.find_element(By.CLASS_NAME, "iip-IntroductoryPopup_Cross")
    popup.click()
except:
    print("Not exist popup")

# Click in login button for open form login
loginButton = Wait(driver, 60).until(EC.presence_of_element_located((By.CLASS_NAME,  "hm-MainHeaderRHSLoggedOutWide_LoginContainer ")))
loginButton.click()

Wait(driver, 60).until(EC.presence_of_element_located((By.CLASS_NAME, "lms-StandardLogin_Username ")))
print("\tinput email")
user = driver.find_element(By.CLASS_NAME, 'lms-StandardLogin_Username ')
user.clear()
user.send_keys(USER)
time.sleep(random.randint(1, 3))
user.send_keys(Keys.TAB)

print("\tinput pwd")
pw = driver.find_element(By.CLASS_NAME, 'lms-StandardLogin_Password ')
pw.send_keys(PASSWORD)
time.sleep(random.randint(1, 3))
pw.send_keys(Keys.ENTER)

Pablo Ruan
  • 1,681
  • 1
  • 17
  • 12