How to add these checks in before Attacking?












0














So my issue is I can't seem to find/write in the correct xpath for "BV" & "enemyLevel"



BV meaning "Battle Value"



I've added a picture to show what I mean enemyLevel + BV



For you to test i've created a user & pass



Game: https://s9-en.bitefight.gameforge.com/user/login
user: testaccount123
pass: python123



I need it to only attack if enemyLevel <= 1, BV <=51



if not "search again"



my code that fails when it hits the page above



from selenium import webdriver
import time
import re

driver = webdriver.Chrome("C:\Users\JC
WIN10\PycharmProjects\BitefightPvpBOT\drivers\chromedriver.exe")

driver.set_page_load_timeout(10)
driver.get("https://s9-en.bitefight.gameforge.com/user/login") # SERVER LOGIN PAGE

driver.find_element_by_name("user").send_keys("testaccount123") # USERNAME
time.sleep(1)
driver.find_element_by_name("pass").send_keys("python123") # PASSWORD
time.sleep(1)
driver.find_element_by_class_name("btn-small").click() # LOGIN BUTTON
time.sleep(1)

driver.get("https://s9-en.bitefight.gameforge.com/robbery/index") # HUNT PAGE
time.sleep(1)
driver.find_element_by_name("optionsearch").click() # Werewolf Hunt
time.sleep(2)

BV = driver.find_element_by_xpath('//td[contains(text(),'')]')
enemyLevel = driver.find_element_by_xpath("//td[contains(text(),'1')]")
print(enemyLevel.text, BV.text)

while enemyLevel <=1, BV <=51:
driver.find_element_by_xpath("//form/div/div/button").click() # ATTACK
time.sleep(1)
if enemyLevel >= 1, BV >=51:
driver.find_element_by_name("optionsearch").click()









share|improve this question



























    0














    So my issue is I can't seem to find/write in the correct xpath for "BV" & "enemyLevel"



    BV meaning "Battle Value"



    I've added a picture to show what I mean enemyLevel + BV



    For you to test i've created a user & pass



    Game: https://s9-en.bitefight.gameforge.com/user/login
    user: testaccount123
    pass: python123



    I need it to only attack if enemyLevel <= 1, BV <=51



    if not "search again"



    my code that fails when it hits the page above



    from selenium import webdriver
    import time
    import re

    driver = webdriver.Chrome("C:\Users\JC
    WIN10\PycharmProjects\BitefightPvpBOT\drivers\chromedriver.exe")

    driver.set_page_load_timeout(10)
    driver.get("https://s9-en.bitefight.gameforge.com/user/login") # SERVER LOGIN PAGE

    driver.find_element_by_name("user").send_keys("testaccount123") # USERNAME
    time.sleep(1)
    driver.find_element_by_name("pass").send_keys("python123") # PASSWORD
    time.sleep(1)
    driver.find_element_by_class_name("btn-small").click() # LOGIN BUTTON
    time.sleep(1)

    driver.get("https://s9-en.bitefight.gameforge.com/robbery/index") # HUNT PAGE
    time.sleep(1)
    driver.find_element_by_name("optionsearch").click() # Werewolf Hunt
    time.sleep(2)

    BV = driver.find_element_by_xpath('//td[contains(text(),'')]')
    enemyLevel = driver.find_element_by_xpath("//td[contains(text(),'1')]")
    print(enemyLevel.text, BV.text)

    while enemyLevel <=1, BV <=51:
    driver.find_element_by_xpath("//form/div/div/button").click() # ATTACK
    time.sleep(1)
    if enemyLevel >= 1, BV >=51:
    driver.find_element_by_name("optionsearch").click()









    share|improve this question

























      0












      0








      0







      So my issue is I can't seem to find/write in the correct xpath for "BV" & "enemyLevel"



      BV meaning "Battle Value"



      I've added a picture to show what I mean enemyLevel + BV



      For you to test i've created a user & pass



      Game: https://s9-en.bitefight.gameforge.com/user/login
      user: testaccount123
      pass: python123



      I need it to only attack if enemyLevel <= 1, BV <=51



      if not "search again"



      my code that fails when it hits the page above



      from selenium import webdriver
      import time
      import re

      driver = webdriver.Chrome("C:\Users\JC
      WIN10\PycharmProjects\BitefightPvpBOT\drivers\chromedriver.exe")

      driver.set_page_load_timeout(10)
      driver.get("https://s9-en.bitefight.gameforge.com/user/login") # SERVER LOGIN PAGE

      driver.find_element_by_name("user").send_keys("testaccount123") # USERNAME
      time.sleep(1)
      driver.find_element_by_name("pass").send_keys("python123") # PASSWORD
      time.sleep(1)
      driver.find_element_by_class_name("btn-small").click() # LOGIN BUTTON
      time.sleep(1)

      driver.get("https://s9-en.bitefight.gameforge.com/robbery/index") # HUNT PAGE
      time.sleep(1)
      driver.find_element_by_name("optionsearch").click() # Werewolf Hunt
      time.sleep(2)

      BV = driver.find_element_by_xpath('//td[contains(text(),'')]')
      enemyLevel = driver.find_element_by_xpath("//td[contains(text(),'1')]")
      print(enemyLevel.text, BV.text)

      while enemyLevel <=1, BV <=51:
      driver.find_element_by_xpath("//form/div/div/button").click() # ATTACK
      time.sleep(1)
      if enemyLevel >= 1, BV >=51:
      driver.find_element_by_name("optionsearch").click()









      share|improve this question













      So my issue is I can't seem to find/write in the correct xpath for "BV" & "enemyLevel"



      BV meaning "Battle Value"



      I've added a picture to show what I mean enemyLevel + BV



      For you to test i've created a user & pass



      Game: https://s9-en.bitefight.gameforge.com/user/login
      user: testaccount123
      pass: python123



      I need it to only attack if enemyLevel <= 1, BV <=51



      if not "search again"



      my code that fails when it hits the page above



      from selenium import webdriver
      import time
      import re

      driver = webdriver.Chrome("C:\Users\JC
      WIN10\PycharmProjects\BitefightPvpBOT\drivers\chromedriver.exe")

      driver.set_page_load_timeout(10)
      driver.get("https://s9-en.bitefight.gameforge.com/user/login") # SERVER LOGIN PAGE

      driver.find_element_by_name("user").send_keys("testaccount123") # USERNAME
      time.sleep(1)
      driver.find_element_by_name("pass").send_keys("python123") # PASSWORD
      time.sleep(1)
      driver.find_element_by_class_name("btn-small").click() # LOGIN BUTTON
      time.sleep(1)

      driver.get("https://s9-en.bitefight.gameforge.com/robbery/index") # HUNT PAGE
      time.sleep(1)
      driver.find_element_by_name("optionsearch").click() # Werewolf Hunt
      time.sleep(2)

      BV = driver.find_element_by_xpath('//td[contains(text(),'')]')
      enemyLevel = driver.find_element_by_xpath("//td[contains(text(),'1')]")
      print(enemyLevel.text, BV.text)

      while enemyLevel <=1, BV <=51:
      driver.find_element_by_xpath("//form/div/div/button").click() # ATTACK
      time.sleep(1)
      if enemyLevel >= 1, BV >=51:
      driver.find_element_by_name("optionsearch").click()






      python selenium browser-automation






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 19 '18 at 13:00









      JC Smyth

      286




      286
























          1 Answer
          1






          active

          oldest

          votes


















          2














          You can check required values as



          enemyLevel = int(driver.find_element_by_xpath('//td[.="Level:"]/following-sibling::td').text)
          BV = int(driver.find_element_by_xpath('//td[.="Battle value:"]/following-sibling::td').text)

          if enemyLevel <= 1 and BV =< 51:
          ...
          else:
          # search for another victim





          share|improve this answer





















          • Thank you so so much!
            – JC Smyth
            Nov 19 '18 at 13:12










          • @JCSmyth Welcome. You can accept the answer if it solved your issue
            – Andersson
            Nov 19 '18 at 16:10










          • There we go! do you have an email I can get in touch with you or discord username?
            – JC Smyth
            Nov 19 '18 at 17:17










          • @JCSmyth , there is no need. Just tag your question with Python and Selenium and I will find your question :)
            – Andersson
            Nov 19 '18 at 18:32










          • ok ^^ thanks again
            – JC Smyth
            Nov 19 '18 at 20:39











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53375223%2fhow-to-add-these-checks-in-before-attacking%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          2














          You can check required values as



          enemyLevel = int(driver.find_element_by_xpath('//td[.="Level:"]/following-sibling::td').text)
          BV = int(driver.find_element_by_xpath('//td[.="Battle value:"]/following-sibling::td').text)

          if enemyLevel <= 1 and BV =< 51:
          ...
          else:
          # search for another victim





          share|improve this answer





















          • Thank you so so much!
            – JC Smyth
            Nov 19 '18 at 13:12










          • @JCSmyth Welcome. You can accept the answer if it solved your issue
            – Andersson
            Nov 19 '18 at 16:10










          • There we go! do you have an email I can get in touch with you or discord username?
            – JC Smyth
            Nov 19 '18 at 17:17










          • @JCSmyth , there is no need. Just tag your question with Python and Selenium and I will find your question :)
            – Andersson
            Nov 19 '18 at 18:32










          • ok ^^ thanks again
            – JC Smyth
            Nov 19 '18 at 20:39
















          2














          You can check required values as



          enemyLevel = int(driver.find_element_by_xpath('//td[.="Level:"]/following-sibling::td').text)
          BV = int(driver.find_element_by_xpath('//td[.="Battle value:"]/following-sibling::td').text)

          if enemyLevel <= 1 and BV =< 51:
          ...
          else:
          # search for another victim





          share|improve this answer





















          • Thank you so so much!
            – JC Smyth
            Nov 19 '18 at 13:12










          • @JCSmyth Welcome. You can accept the answer if it solved your issue
            – Andersson
            Nov 19 '18 at 16:10










          • There we go! do you have an email I can get in touch with you or discord username?
            – JC Smyth
            Nov 19 '18 at 17:17










          • @JCSmyth , there is no need. Just tag your question with Python and Selenium and I will find your question :)
            – Andersson
            Nov 19 '18 at 18:32










          • ok ^^ thanks again
            – JC Smyth
            Nov 19 '18 at 20:39














          2












          2








          2






          You can check required values as



          enemyLevel = int(driver.find_element_by_xpath('//td[.="Level:"]/following-sibling::td').text)
          BV = int(driver.find_element_by_xpath('//td[.="Battle value:"]/following-sibling::td').text)

          if enemyLevel <= 1 and BV =< 51:
          ...
          else:
          # search for another victim





          share|improve this answer












          You can check required values as



          enemyLevel = int(driver.find_element_by_xpath('//td[.="Level:"]/following-sibling::td').text)
          BV = int(driver.find_element_by_xpath('//td[.="Battle value:"]/following-sibling::td').text)

          if enemyLevel <= 1 and BV =< 51:
          ...
          else:
          # search for another victim






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 19 '18 at 13:09









          Andersson

          37.2k103266




          37.2k103266












          • Thank you so so much!
            – JC Smyth
            Nov 19 '18 at 13:12










          • @JCSmyth Welcome. You can accept the answer if it solved your issue
            – Andersson
            Nov 19 '18 at 16:10










          • There we go! do you have an email I can get in touch with you or discord username?
            – JC Smyth
            Nov 19 '18 at 17:17










          • @JCSmyth , there is no need. Just tag your question with Python and Selenium and I will find your question :)
            – Andersson
            Nov 19 '18 at 18:32










          • ok ^^ thanks again
            – JC Smyth
            Nov 19 '18 at 20:39


















          • Thank you so so much!
            – JC Smyth
            Nov 19 '18 at 13:12










          • @JCSmyth Welcome. You can accept the answer if it solved your issue
            – Andersson
            Nov 19 '18 at 16:10










          • There we go! do you have an email I can get in touch with you or discord username?
            – JC Smyth
            Nov 19 '18 at 17:17










          • @JCSmyth , there is no need. Just tag your question with Python and Selenium and I will find your question :)
            – Andersson
            Nov 19 '18 at 18:32










          • ok ^^ thanks again
            – JC Smyth
            Nov 19 '18 at 20:39
















          Thank you so so much!
          – JC Smyth
          Nov 19 '18 at 13:12




          Thank you so so much!
          – JC Smyth
          Nov 19 '18 at 13:12












          @JCSmyth Welcome. You can accept the answer if it solved your issue
          – Andersson
          Nov 19 '18 at 16:10




          @JCSmyth Welcome. You can accept the answer if it solved your issue
          – Andersson
          Nov 19 '18 at 16:10












          There we go! do you have an email I can get in touch with you or discord username?
          – JC Smyth
          Nov 19 '18 at 17:17




          There we go! do you have an email I can get in touch with you or discord username?
          – JC Smyth
          Nov 19 '18 at 17:17












          @JCSmyth , there is no need. Just tag your question with Python and Selenium and I will find your question :)
          – Andersson
          Nov 19 '18 at 18:32




          @JCSmyth , there is no need. Just tag your question with Python and Selenium and I will find your question :)
          – Andersson
          Nov 19 '18 at 18:32












          ok ^^ thanks again
          – JC Smyth
          Nov 19 '18 at 20:39




          ok ^^ thanks again
          – JC Smyth
          Nov 19 '18 at 20:39


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53375223%2fhow-to-add-these-checks-in-before-attacking%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          MongoDB - Not Authorized To Execute Command

          in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith

          How to fix TextFormField cause rebuild widget in Flutter