I want to run the game on this page 100 times, and each time, pull out the final metric:
Step: 1000 x = (7,1,9,10) a = (0) y = (7,1,8,10) Bad steps: 148 Good steps: 852 Score: 85.20% Run over.
I can see where the line is in the console:
So I wrote this:
from selenium import webdriver
import os
from selenium.webdriver.support.ui import Select
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.options import Options
import pandas as pd
import time
import sys
import re
import requests
options = Options()
#options.binary_location=r'/usr/local/bin/'
options.add_experimental_option('excludeSwitches', ['enable-logging'])
options.add_argument("--headless")
driver = webdriver.Chrome(options=options,executable_path='/usr/local/bin/chromedriver')
output_file = open('output.txt', 'a')
driver.get('https://run.ancientbrain.com/run.php?world=complex&mind=complex')
field = driver.find_element_by_xpath('user_span1')
print(field.text)
The error is:
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"user_span1"}
I understand it's saying that it can't find the tag I'm looking for, could someone demonstrate how to pull out the text in the tag I'm looking for (user_span1 and user_span2)? I want to test my code (not shown here, not relevent) by running the code multiple times and comparing the bad steps/good steps/score to a different set of runs using different code parameters so I want to pull out this metric for a set of runs....I could do it manually, but I've been wanting to improve my selenium anyway.
p.s. I have seen similar questions, and I know how to do this when the span is static on the webpage with beautifulSoup etc, but when i click inspect on this page, the tag I want is not there, so I don't think it's a straightforward job with beautifulSoup/pandas/I haven't seen an answer that specifically answers this case.

