2017-04-22 5 views
0

私は、ブラウザゲームでボットとしてsplinterを使用しようとしています。
これは私がちょうどこのSplinter .type()text then variable

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) 
ある場合、それが正常に動作し、私のメインのコードブロック

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") 

です

とにかくこれを行うには?

答えて

0

私はこれを入力したので、私はちょうどそれが動作する二つの異なるラインをすれば、私は答え

if intCommand == mainMess.find_by_css('.chatMessage-message').text: 
    browser.find_by_id('chat_input').type("You are ") 
    browser.find_by_id('chat_input').type(userName) 
    browser.find_by_id('chat_submit').click() 
    print("Reply Sent") 

を考え出しました。おそらく最も効率的ではないが、それは仕事をする

関連する問題