-
| I try to make a github action with my script(work fine in my window 11 computer) like in the last youtube video Unlimited Free Web-Scraping with GitHub Actions. After few hours i was able to run the github action but i get this error: iam only testing realistic_browser_history(sb) but for some reason don This is my code: from seleniumbase import SB
import random
import os
URL_OVERVIEW = 'http://srv220118-206152.vps.etecsa.cu/game.php?page=overview'
URL_HASH = 'http://srv220118-206152.vps.etecsa.cu/game.php?page=overview'
LOGIN = "/html/body/section/div[2]/div/div[2]/div/div[2]/form/div[4]/button"
TOKEN = os.environ["TOKEN"]
CHAT_ID = os.environ["CHAT_ID"]
USERNAME = os.environ["USERNAME"]
PASSWORD = os.environ["PASSWORD"]
RANDOM_SLEEP = float(random.randint(40, 80) / 50)
# MAIN BUTTONS:
ESTRUCTURAS = 'span:contains("Estructuras")'
TECNOLOGIAS = 'span:contains("Tecnologías")'
FLOTAS = 'span:contains("Flotas")'
DEFENSA = 'span:contains("Defensas")'
RECURSOS = 'span:contains("Recursos")'
def realistic_browser_history(sb):
   url = "https://www.google.com/"
   sb.activate_cdp_mode(url)
   sb.cdp.sleep(RANDOM_SLEEP)
   sb.cdp.sleep(6)
   sb.cdp.send_keys("APjFqb", "ogame\n")
   print('ogame Suscesfully!')
   sb.cdp.sleep(RANDOM_SLEEP)
   sb.cdp.send_keys("APjFqb", "ogame wikipedia\n")
   print('ogame wikipedia Suscesfully!')
   sb.cdp.sleep(RANDOM_SLEEP)
   sb.cdp.click('h3:contains("OGame - Wikipedia, la enciclopedia libre")')
   print('History Suscesfully!')
   sb.cdp.sleep(RANDOM_SLEEP)
def antibot_detection(sb):
   url = "https://seleniumbase.io/antibot/login"
   sb.activate_cdp_mode(url)
   sb.cdp.sleep(RANDOM_SLEEP)
   sb.press_keys("input#username", "demo_user")
   sb.cdp.sleep(RANDOM_SLEEP)
   sb.press_keys("input#password", "secret_pass")
   x, y = sb.cdp.get_gui_element_center("button#myButton")
   sb.cdp.sleep(RANDOM_SLEEP)
   sb.uc_gui_click_x_y(x, y)
   sb.sleep(1.5)
   x, y = sb.cdp.get_gui_element_center("a#log-in")
   sb.uc_gui_click_x_y(x, y)
   sb.assert_text("Welcome!", "h1")
   sb.cdp.sleep(RANDOM_SLEEP)
   sb.set_messenger_theme(location="bottom_center")
   sb.post_message("SeleniumBase wasn't detected!")
   sb.cdp.sleep(RANDOM_SLEEP)
   sb.sleep(15)
   print("Bot detected!")
   sb.cdp.sleep(15)
def browser_scan(sb):
   url = "https://www.browserscan.net/bot-detection"
   sb.activate_cdp_mode(url)
   sb.sleep(1)
   sb.cdp.flash("Test Results", duration=4)
   sb.sleep(5)
   sb.cdp.assert_element('strong:contains("Normal")')
   sb.cdp.sleep(RANDOM_SLEEP)
   sb.cdp.flash('strong:contains("Normal")', duration=4, pause=4)
   sb.sleep(5)
   print('Bot detected!')
   sb.cdp.sleep(RANDOM_SLEEP)
def fingerprint(sb):
   url = "https://demo.fingerprint.com/playground"
   sb.activate_cdp_mode(url)
   sb.sleep(1)
   sb.cdp.highlight('a[href*="browser-bot-detection"]')
   bot_row_selector = 'table:contains("Bot") tr:nth-of-type(3)'
   print(sb.cdp.get_text(bot_row_selector))
   sb.cdp.assert_text("Bot Not detected", bot_row_selector)
   sb.cdp.highlight(bot_row_selector)
   sb.sleep(2)
   print('Bot detected!')
   sb.cdp.sleep(RANDOM_SLEEP)
# driver.close()
def checkLogin(sb):
   sb.cdp.sleep(6)
   if isLogin(sb):
       pass
   else:
       login(sb)
def isLogin(sb):
   sb.activate_cdp_mode(URL_OVERVIEW)
   content = sb.cdp.find_element("#content")
   if content:
       print('IsLogin')
       return True
   else:
       print('Isn`t Login')
       return False
   print('Isn`t Login')
   return False
def login(sb):
   print("Logueando...")
   sb.activate_cdp_mode("http://srv220118-206152.vps.etecsa.cu/index.php")
   sb.cdp.sleep(RANDOM_SLEEP)
   sb.cdp.send_keys('#username', USERNAME)
   sb.cdp.sleep(RANDOM_SLEEP)
   sb.cdp.send_keys('#password', PASSWORD)
   sb.cdp.sleep(RANDOM_SLEEP)
   sb.cdp.click_if_visible(LOGIN)
   sb.sleep(6)
   print("Logueado!")
   
def main(SB):
   with SB(uc=True, test=True) as sb:
       # login(sb)
       realistic_browser_history(sb)
main(SB)This is my yaml file: name: Run Windows Bot
on:
  workflow_dispatch:  # Allows manual trigger
  schedule:
    - cron: '0 */6 * * *'  # Runs every 6 hours
jobs:
  run-bot:
    runs-on: windows-latest
    
    steps:
    - name: Checkout repository
      uses: actions/checkout@v3
      
    - name: Set up Python
      uses: actions/setup-python@v4
      with:
        python-version: '3.10'
    - name: Install Chrome and Chrome Driver
      run: |
        choco install googlechrome -y
        choco install chromedriver -y 
    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip
        pip install seleniumbase
    - name: Run python script
      env:
        TOKEN: ${{ secrets.TOKEN }}
        CHAT_ID: ${{ secrets.CHAT_ID }}
        USERNAME: ${{ secrets.USERNAME }}
        PASSWORD: ${{ secrets.PASSWORD }}
      run: |
        python examples/my_examples/sb_xnova_bot_wop_xnproyect.py --browser=chrome --headless -v -s --junit-xml=junit/test-results.xml
         | 
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
| 
 
 
 | 
Beta Was this translation helpful? Give feedback.
APjFqbis not a valid CSS Selector.'[title="Search"]'is the correct selector for the Google search box.