Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Element not found in Github Actions #3431

Answered by mdmintz
Pedro0152 asked this question in Q&A
Discussion options

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:

Warning: uc_driver not found. Getting it now:
*** chromedriver to download = 132.0.6834.83 (Latest Stable) 
Downloading chromedriver-win64.zip from:
https://storage.googleapis.com/chrome-for-testing-public/132.0.6834.83/win64/chromedriver-win64.zip ...
Download Complete!
Extracting ['chromedriver.exe'] from chromedriver-win64.zip ...
Unzip Complete!
The file [uc_driver.exe] was saved to:
C:\hostedtoolcache\windows\Python3円.10.11\x64\Lib\site-packages\seleniumbase\drivers\
uc_driver.exe
Making [uc_driver.exe 132.0.6834.83] executable ...
[uc_driver.exe 132.0.6834.83] is now ready for use!
*** chromedriver to download = 132.0.6834.83 (Latest Stable) 
Downloading chromedriver-win64.zip from:
https://storage.googleapis.com/chrome-for-testing-public/132.0.6834.83/win64/chromedriver-win64.zip ...
Download Complete!
Extracting ['chromedriver.exe'] from chromedriver-win64.zip ...
Unzip Complete!
The file [chromedriver.exe] was saved to:
C:\hostedtoolcache\windows\Python3円.10.11\x64\Lib\site-packages\seleniumbase\drivers\
chromedriver.exe
Making [chromedriver.exe 132.0.6834.83] executable ...
[chromedriver.exe 132.0.6834.83] is now ready for use!
Traceback (most recent call last):
 File "C:\hostedtoolcache\windows\Python3円.10.11\x64\lib\site-packages\seleniumbase\plugins\sb_manager.py", line 1[22](https://github.com/Pedro0152/SeleniumBase/actions/runs/12843844587/job/35816240244#step:6:23)3, in SB
 yield sb
 File "D:\a\SeleniumBase\SeleniumBase\examples\my_examples\sb_xnova_bot_wop_xnproyect.py", line 135, in main
 realistic_browser_history(sb)
 File "D:\a\SeleniumBase\SeleniumBase\examples\my_examples\sb_xnova_bot_wop_xnproyect.py", line [29](https://github.com/Pedro0152/SeleniumBase/actions/runs/12843844587/job/35816240244#step:6:30), in realistic_browser_history
 sb.cdp.send_keys("APjFqb", "ogame\n")
 File "C:\hostedtoolcache\windows\Python3円.10.11\x64\lib\site-packages\seleniumbase\core\sb_cdp.py", line 792, in send_keys
 element = self.select(selector, timeout=timeout)
 File "C:\hostedtoolcache\windows\Python3円.10.11\x64\lib\site-packages\seleniumbase\core\sb_cdp.py", line [30](https://github.com/Pedro0152/SeleniumBase/actions/runs/12843844587/job/35816240244#step:6:31)9, in select
 raise Exception(message)
Exception: 
 Element {APjFqb} was not found after 7 seconds!
=========== {sb_xnova_bot_wop_xnproyect.py:138:SB} failed in [34](https://github.com/Pedro0152/SeleniumBase/actions/runs/12843844587/job/35816240244#step:6:35).51s ============

iam only testing realistic_browser_history(sb) but for some reason dont see the googles search bar (APjFqb)

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:
already test with :
python examples/my_examples/sb_xnova_bot_wop_xnproyect.py --browser=chrome
but got the same error.

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
You must be logged in to vote

Element {APjFqb} was not found after 7 seconds!

APjFqb is not a valid CSS Selector.

'[title="Search"]' is the correct selector for the Google search box.

Replies: 1 comment

Comment options

Element {APjFqb} was not found after 7 seconds!

APjFqb is not a valid CSS Selector.

'[title="Search"]' is the correct selector for the Google search box.

You must be logged in to vote
0 replies
Answer selected by mdmintz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /