charlesbel / Microsoft-Rewards-Farmer

A simple bot that uses selenium to farm Microsoft Rewards written in Python
MIT License
1.02k stars 273 forks source link

NoSuchElementException Error on quiz #23

Closed njhughesSAS closed 3 years ago

njhughesSAS commented 3 years ago

looks like we have a new lost element. Traceback (most recent call last): File "c:\Users\User\Documents\Microsoft-Rewards-Farmer-master\test\import time_n.py", line 520, in <module> completeDailySet(browser) File "c:\Users\User\Documents\Microsoft-Rewards-Farmer-master\test\import time_n.py", line 372, in completeDailySet completeDailySetSurvey(browser, cardNumber) File "c:\Users\User\Documents\Microsoft-Rewards-Farmer-master\test\import time_n.py", line 242, in completeDailySetSurvey browser.find_element_by_xpath('//*[@id="daily-sets"]/mee-card-group[1]/div/mee-card[' + str(cardNumber) + ']/div/card-content/mee-rewards-daily-set-item-content/div/div[3]/a').click() File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 368, in find_element_by_xpath return self.find_element(by=By.XPATH, value=xpath) File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 856, in find_element return self.execute(Command.FIND_ELEMENT, { File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 311, in execute self.error_handler.check_response(response) File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 237, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="daily-sets"]/mee-card-group[1]/div/mee-card[3]/div/card-content/mee-rewards-daily-set-item-content/div/div[3]/a"} (Session info: chrome=87.0.4280.88) Here is our source code https://gist.github.com/njhughesSAS/c1d0b52b004303b56b1bd0a66f71388c

Should we put all the features in a try except clause so even if we have a NoSuchElement Error it will move on to the rest of the script and do our searches

njhughesSAS commented 3 years ago

Traceback (most recent call last): File "c:\Users\User\Documents\Microsoft-Rewards-Farmer-master\test\import time_n.py", line 520, in <module> completeDailySet(browser) File "c:\Users\User\Documents\Microsoft-Rewards-Farmer-master\test\import time_n.py", line 372, in completeDailySet completeDailySetSurvey(browser, cardNumber) File "c:\Users\User\Documents\Microsoft-Rewards-Farmer-master\test\import time_n.py", line 242, in completeDailySetSurvey browser.find_element_by_xpath('//*[@id="daily-sets"]/mee-card-group[1]/div/mee-card[' + str(cardNumber) + ']/div/card-content/mee-rewards-daily-set-item-content/div/div[3]/a').click() File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 368, in find_element_by_xpath return self.find_element(by=By.XPATH, value=xpath) File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 856, in find_element return self.execute(Command.FIND_ELEMENT, { File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 311, in execute self.error_handler.check_response(response) File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 237, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="daily-sets"]/mee-card-group[1]/div/mee-card[3]/div/card-content/mee-rewards-daily-set-item-content/div/div[3]/a"} (Session info: chrome=87.0.4280.88) quiz source https://gist.github.com/njhughesSAS/c8c73b67037ddda008b905051f4b0489 today's dashboard https://gist.github.com/njhughesSAS/4cfbc44e1be7507e386ddc038255fe39

charlesbel commented 3 years ago

Could you go to your dashboard, and make inspect element on the <a> tag of the quiz (the button to go to the quiz), and then make copy xpath on the tag. Then share me this xpath.

njhughesSAS commented 3 years ago

//*[@id="daily-sets"]/mee-card-group[1]/div/mee-card[2]/div/card-content/mee-rewards-daily-set-item-content/div/div[3]/a

njhughesSAS commented 3 years ago

Looks like card number is incorrect right it looks like it is not catching ABC quiz and moving on to card 3 which breaks the url since card 2 was not actually completed as it is taking the ABC quiz as True or False

charlesbel commented 3 years ago

Fixed !

njhughesSAS commented 3 years ago

last commit is missing lines

Define user-agents

PC_USER_AGENT = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.74 Safari/537.36 Edg/79.0.309.43' MOBILE_USER_AGENT = 'Mozilla/5.0 (Android 6.0.1; Mobile; rv:77.0) Gecko/77.0 Firefox/77.0'

creating PC_USER_AGENT not defined

charlesbel commented 3 years ago

last commit is missing lines

Define user-agents

PC_USER_AGENT = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.74 Safari/537.36 Edg/79.0.309.43' MOBILE_USER_AGENT = 'Mozilla/5.0 (Android 6.0.1; Mobile; rv:77.0) Gecko/77.0 Firefox/77.0'

creating PC_USER_AGENT not defined

Thanks I missed it :)

njhughesSAS commented 3 years ago

It also skips over the A, B, or C quiz and moves on to complete the 3rd.

charlesbel commented 3 years ago

It also skips over the A, B, or C quiz and moves on to complete the 3rd.

It should complete the ABC quiz from "daily set" and "more promotions" now !