硒不咔嗒



我正在为带有硒铬驱动程序的cookieclickerbot制作脚本。 问题是它既没有点击cookie也没有升级。 我已经玩了大约两天的代码,但我对课程没有经验。 请测试一下,看看你是否能解决它,不要担心以不同的方式安排课程,我只是想看看我做错了什么。 希望你也可以解释一下,这样我就可以更多地了解硒、python 和类。

from selenium import webdriver
from time import sleep
class COOKIEBOT2000(object):
def __init__(self,upgrade=1,click=1,prints=1):
self.upgrade = upgrade
self.click = click
self.prints = prints
self.cursor = 0
self.grandma = 0
self.farm = 0
self.mine = 0
self.factory = 0
self.temple = 0
self.wizard = 0
self.driver = webdriver.Chrome ("Path too chromedriver")
def Clicker(self):
try:
if self.click == 1:
if self.prints == 1:
print ("clicking")
print(self.driver)
i = 0
while i < 11:
click = driver.find_element_by_id("bigCookie")
click.click()
i = i + 1
print (i)
if self.prints == 1:
click = driver.find_element_by_id("cookies")
click.click()
click = click.text
money = click.split("n")
money = money[0].split(" ")
money = int(money[0])
print (money)
self.Upgrader()
except:
self.Upgrader()
def Upgrader(self):
if self.upgrade == 1:
if self.prints == 1:
print ("Upgrading")
try:
click = driver.self.find_element_by_id("product0")
if click.get_attribute("class") == "product unlocked enabled":
if self.cursor < 51:
click.click()
self.cursor = self.cursor + 1
click = driver.self.find_element_by_id("product1")
if click.get_attribute("class") == "product unlocked enabled":
if self.grandma < 7:
click.click()
self.grandma = self.grandma + 1
click = driver.self.find_element_by_id("product2")
if click.get_attribute("class") == "product unlocked enabled":
if self.farm < 41:
click.click()
self.farm = self.farm + 1
click = driver.self.find_element_by_id("product3")
if click.get_attribute("class") == "product unlocked enabled":
if self.mine < 41:
click.click()
self.mine = self.mine + 1
click = driver.self.find_element_by_id("product4")
if click.get_attribute("class") == "product unlocked enabled":
if self.factory < 51:
click.click()
self.factory = self.factory + 1
click = driver.self.find_element_by_id("product5")
if click.get_attribute("class") == "product unlocked enabled":
if self.temple < 51:
click.click()
self.temple = self.temple + 1
click = driver.self.find_element_by_id("product6")
if click.get_attribute("class") == "product unlocked enabled":
if self.wizard < 51:
click.click()
self.wizard = self.wizard + 1
self.Clicker()
except:
self.Clicker()
return
def Start(self):
self.driver.get("http://orteil.dashnet.org/cookieclicker/")
sleep(1)
if self.prints == 1:
print("begun")
self.Clicker()
CK = COOKIEBOT2000()
CK.Start()

在你的Clicker函数中,替换这个的每个实例,这对你来说一定是一个愚蠢的错误——

driver.find_element_by_id

由此——

self.driver.find_element_by_id

然后,在您的Upgrader函数中,替换此函数的每个实例-

driver.self.find_element_by_id

通过这个——

self.driver.find_element_by_id 

这样做将使脚本作为游戏的一部分连续执行所有点击。

相关内容

  • 没有找到相关文章

最新更新