klept0 / MS-Rewards-Farmer

A simple bot that uses Selenium to farm M$ Rewards in Python
MIT License
239 stars 49 forks source link

Error on "Starting Desktop Edge Bing Searches. . ." #191

Open SilverStallionAlpha opened 2 months ago

SilverStallionAlpha commented 2 months ago

Before submitting a bug report...

Branch

master

Commit

0a94091

Describe the bug

Everytime I run main.py, I always get the error on "Starting Desktop Edge Bing searches...". I tried with and without headless mode, I cleared sessions folder, killed all chrome processes, and the problem still persists.

Copy and paste your error

←[38;5;39m2024-08-28 10:24:32,307 [INFO] Screen size: 2372x1518←[0m ←[38;5;39m2024-08-28 10:24:32,307 [INFO] Device size: 2317x1367←[0m ←[38;21m2024-08-28 10:24:32,345 [DEBUG] out init←[0m ←[38;21m2024-08-28 10:24:32,346 [DEBUG] in enter←[0m ←[38;5;39m2024-08-28 10:24:43,368 [INFO] [LOGIN] Already logged-in←[0m ←[38;5;39m2024-08-28 10:24:54,322 [INFO] [POINTS] You have 0.00 points on your account←[0m ←[38;5;39m2024-08-28 10:24:54,323 [INFO] [DAILY SET] Trying to complete the Daily Set...←[0m ←[38;5;39m2024-08-28 10:24:59,634 [INFO] [DAILY SET] Exiting←[0m ←[38;5;39m2024-08-28 10:24:59,636 [INFO] [PUNCH CARDS] Trying to complete the Punch Cards...←[0m ←[38;5;39m2024-08-28 10:25:20,909 [INFO] [PUNCH CARDS] Exiting←[0m ←[38;5;39m2024-08-28 10:25:20,909 [INFO] [MORE PROMOS] Trying to complete More Promotions...←[0m ←[38;21m2024-08-28 10:25:29,890 [DEBUG] promotionTitle=Soccer legend←[0m ←[38;21m2024-08-28 10:25:29,890 [DEBUG] Already done, continuing←[0m ←[38;21m2024-08-28 10:25:29,891 [DEBUG] promotionTitle=It's all Greek←[0m ←[38;21m2024-08-28 10:25:29,891 [DEBUG] Already done, continuing←[0m ←[38;21m2024-08-28 10:25:29,891 [DEBUG] promotionTitle=Dinner ideas←[0m ←[38;21m2024-08-28 10:25:29,891 [DEBUG] Already done, continuing←[0m ←[38;21m2024-08-28 10:25:29,891 [DEBUG] promotionTitle=Lock and key←[0m ←[38;21m2024-08-28 10:25:29,891 [DEBUG] Already done, continuing←[0m ←[38;21m2024-08-28 10:25:29,892 [DEBUG] promotionTitle=A new web hero←[0m ←[38;21m2024-08-28 10:25:29,892 [DEBUG] Already done, continuing←[0m ←[38;5;39m2024-08-28 10:25:35,755 [INFO] [MORE PROMOS] Exiting←[0m ←[38;5;39m2024-08-28 10:25:35,756 [INFO] [BING] Starting Desktop Edge Bing searches...←[0m ←[38;21m2024-08-28 10:25:44,280 [DEBUG] in exit exc_type=<class 'KeyError'> exc_value='pcSearch' traceback=<traceback object at 0x00000208696A4400>←[0m ←[38;5;196m2024-08-28 10:25:44,538 [ERROR] ←[0m Traceback (most recent call last): File "C:\Users\andreas\Downloads\MS-Rewards-Farmer-master\MS-Rewards-Farmer-master\main.py", line 40, in main earned_points = executeBot(currentAccount, args) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\andreas\Downloads\MS-Rewards-Farmer-master\MS-Rewards-Farmer-master\main.py", line 249, in executeBot searches.bingSearches() File "C:\Users\andreas\Downloads\MS-Rewards-Farmer-master\MS-Rewards-Farmer-master\src\searches.py", line 119, in bingSearches while (remainingSearches := self.browser.getRemainingSearches()) > 0: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\andreas\Downloads\MS-Rewards-Farmer-master\MS-Rewards-Farmer-master\src\browser.py", line 238, in getRemainingSearches progressDesktop = counters["pcSearch"][0]["pointProgress"]


KeyError: 'pcSearch'
←[38;5;226m2024-08-28 10:25:44,541 [WARNING] config-private.yaml doesn't exist←[0m
←[38;21m2024-08-28 10:25:44,541 [DEBUG] No urls found, not sending notification←[0m
←[38;5;39m2024-08-28 10:25:44,542 [INFO] [POINTS] Data saved for the next day.←[0m

### Screenshots

None. The state of chrome doesn't change during the error.

### Value of dashboard variable

N/A
Ices-Eyes commented 2 months ago

You have to create your config-private.yaml file as stated in the readme

SilverStallionAlpha commented 2 months ago

You have to create your config-private.yaml file as stated in the readme

I can't seem to find the section about config-private.yaml in the readme. Do you mind telling me how I can do that or where to find the guide?

Ices-Eyes commented 2 months ago

Sorry, it is in the changelog of 1.0.0 version

https://github.com/klept0/MS-Rewards-Farmer/blob/master/CHANGELOG.md

SilverStallionAlpha commented 2 months ago

Sorry, it is in the changelog of 1.0.0 version

https://github.com/klept0/MS-Rewards-Farmer/blob/master/CHANGELOG.md

I managed to setup the config-private.yaml, setting the webhook to discord. However I'm still stuck on "Starting Desktop Edge Bing Searches" with the error log as follows:


  File "C:\Users\andreas\Downloads\MS-Rewards-Farmer-master\MS-Rewards-Farmer-master\main.py", line 40, in main
    earned_points = executeBot(currentAccount, args)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\andreas\Downloads\MS-Rewards-Farmer-master\MS-Rewards-Farmer-master\main.py", line 249, in executeBot
    searches.bingSearches()
  File "C:\Users\andreas\Downloads\MS-Rewards-Farmer-master\MS-Rewards-Farmer-master\src\searches.py", line 119, in bingSearches
    while (remainingSearches := self.browser.getRemainingSearches()) > 0:
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\andreas\Downloads\MS-Rewards-Farmer-master\MS-Rewards-Farmer-master\src\browser.py", line 238, in getRemainingSearches
    progressDesktop = counters["pcSearch"][0]["pointProgress"]
                      ~~~~^^^^^^^^^^^^
KeyError: 'pcSearch'
cal4 commented 2 months ago

So configuring config-private.yaml's a bit of a red herring. I may change that logging from warning to info since it's normal to not have it.

I have seen this issue, which has been exposed I believe by the new way we figure the search count for searches.py. Rather than checking this once per run per desktop/mobile, we recheck every run. There have been times where it fails.

That being said, in your case it fails on the first try, which I haven't seen. What I'd suggest to do is run the app/pause the scraper part with a debugger or isolate the launching of Chrome part and run just that. Then, try going to the rewards page and see what happens when you attempt.

SilverStallionAlpha commented 2 months ago

So configuring config-private.yaml's a bit of a red herring. I may change that logging from warning to info since it's normal to not have it.

I have seen this issue, which has been exposed I believe by the new way we figure the search count for searches.py. Rather than checking this once per run per desktop/mobile, we recheck every run. There have been times where it fails.

That being said, in your case it fails on the first try, which I haven't seen. What I'd suggest to do is run the app/pause the scraper part with a debugger or isolate the launching of Chrome part and run just that. Then, try going to the rewards page and see what happens when you attempt.

Hi thanks for the reply, I tried debugging and found several errors:

First is this: on browser.py, line 238 it tried to look for "pcSearch", however 'counters' doesn't contain the value. image

Second: in the function bingSearcher on searches.py, I received the error Operator ">" not supported for types "RemainingSearches | int" and "Literal[0]" Operator ">" not supported for types "RemainingSearches" and "Literal[0]"

Thank you for the help, I appreciate it. Please let me know if you need any more info

Calvineries commented 1 month ago
Traceback (most recent call last):
  File "C:\Users\Mudkip\Documents\MS-Rewards\main.py", line 39, in main
    earned_points = executeBot(currentAccount, args)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Mudkip\Documents\MS-Rewards\main.py", line 246, in executeBot
    searches.bingSearches()
  File "C:\Users\Mudkip\Documents\MS-Rewards\src\searches.py", line 110, in bingSearches
    desktopAndMobileRemaining = self.browser.getRemainingSearches(
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Mudkip\Documents\MS-Rewards\src\browser.py", line 282, in getRemainingSearches
    pcSearch: dict = counters["PCSearch"][0]
                     ~~~~~~~~^^^^^^^^^^^^
KeyError: 'PCSearch'

Same issue for several days, even with last dev version. For me it occurs on W11 and Ubuntu, on wifi and 5G. I tried to clear all selenium and chrome drivers folders, use argument -l EN -g US, -l FR -g FR , ..

Any solution?

cal4 commented 1 month ago

It takes a while for these keys to appear. I'd suggest checking out the develop branch, deleting the sessions folder, re-logging in and try a few times throughout the day.