Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

122
Vistas
AppleScript to click on webpage with colour

I am using AppleScript to open online meeting. Here among 5 tabs i should click on the green colour(current meeting) tab. Any idea how to getElementBy 'background' colour.

to clickClassName(theClassName, elementnum)
    
    tell application "Safari"
        
        do JavaScript "document.getElementsByClassName('" & theClassName & "')[" & elementnum & "].click();" in document 1
        
    end tell
    
end clickClassName

tell application "Safari"
    activate
    open location "https://myclass.lpu.in/"
    delay 5
    
    tell application "System Events" to tell process "Safari"
        keystroke "USERNAME"
        delay 0.2
        keystroke tab
        delay 0.2
        keystroke "PASSWORD"
        delay 1
        keystroke return
        delay 5
    end tell
end tell

clickClassName("btn stretched-link text-white w-100", 0)

Here at last i need to add a function to open that green tab.

As in the picture there are 5 tags for 5 meetings ClassName is same so only background colour is unique in them

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I will help you with the solution. You must not credit my solution to another user, otherwise I will never help you again. Add following to the end of your script.

set classNames to {"fc-time-grid-event fc-event fc-start fc-end", "fc-time-grid-event fc-event fc-start fc-end fc-time-grid-event-inset"}
set notFounded to true

tell application "Safari"
    repeat with className in classNames
        if notFounded then
            
            -- count all elements of  indicated class
            set theCount to (do JavaScript "document.getElementsByClassName(className).length;" in document 1) as integer
            
            if theCount > 0 then -- find element with "background: green" and click it
                repeat with i from 0 to theCount - 1
                    set theStyle to (do JavaScript "(document.getElementsByClassName(className)[" & i & "]).getAttribute('style');" in document 1) as text
                    if theStyle contains "background: green;" then
                        do JavaScript "(document.getElementsByClassName(className)[" & i & "]).click();" in document 1
                        set notFounded to false
                        exit repeat
                    end if
                end repeat
            end if
            
        end if
    end repeat
end tell
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda