0
我正在嘗試在瀏覽器遊戲中將splinter用作bot。
這是我主要的代碼塊Splinter .type()文本然後變量
lastMess = ""
mainMess = ""
userName = ""
bailOut = 0
intCommand = "/whoami"
while bailOut == 0:
if browser.find_by_css('.chatMessage-main').first.text != lastMess:
lastMess = browser.find_by_css('.chatMessage-main').first.text
mainMess = browser.find_by_css('.chatMessage-main').first
userName = mainMess.find_by_css('.chatMessage-text').first.text
print(browser.find_by_css('.chatMessage-main').first.text)
print(mainMess.find_by_css('.chatMessage-message').text)
if intCommand == mainMess.find_by_css('.chatMessage-message').text:
browser.find_by_id('chat_input').type("You are ",userName)
print(browser.find_by_id('chat_input').type("You are ",userName))
browser.find_by_id('chat_submit').click()
print("Reply Sent")
它可以正常工作,如果我只是這樣做
browser.find_by_id('chat_input').type("You are")
或
browser.find_by_id('chat_input').type(userName)
但如果他們在一起
browser.find_by_id('chat_input').type("You are ",userName)
有沒有辦法做到這一點?