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

182
Vistas
How is chrome made to ignore javascript and how to overcome this?

Some website respond to javascript instructions and some do not. Santanders website allows javascript on the very front page but once you try to log in things change. the following passed in from python will print to console on the front page but not the second page.

driver.execute_script('console.log(" lll kkk cheaky breeki ");')

i can still just open up the developer tools and type

console.log(" lll kkk cheaky breeki ");

and it still works when i do it manually, but not when passed in by python.

my full script is below

import time
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
import selenium.common.exceptions as s_ex

driver = webdriver.Chrome("chromedriver.exe")
driver.get("https://www.santander.co.uk/")
login_xp = '/html/body/div[3]/header/div[1]/div/nav/div/div[1]/div/div/nav/ul/li[2]/a';
time.sleep(1)
driver.execute_script('console.log(" i print fine  ");')
WebDriverWait(driver,10).until(EC.presence_of_element_located((By.XPATH,login_xp)))
log = driver.find_element_by_xpath(login_xp)
log.click();
time.sleep(2)
driver.execute_script('console.log(" lll kkk cheaky breeki ");')  ## how can i get this to print, why doesnt it now?
  1. how do i make this page accept js?
  2. why does it not accept js now?
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

I've tried your example - it looks like the line log.click() makes the browser open a new tab. When that happens, your driver is still pointing at the original tab with the homepage.

Running driver.execute_script('console.log(" lll kkk cheaky breeki ");') at this point will execute the script in the original tab, not in the new one.

If you want to run a script on the log in page, I'd suggest going there directly using, for example:

driver.get('https://retail.santander.co.uk/olb/app/logon/access/#/logon')
about 4 years ago · Juan Pablo Isaza Denunciar

0

The problem is that log.click() opens a new tab. So you need to tell the driver to switch to that new tab and execute all statements on that tab from now on. You will find that currently the driver also can't find any elements on the new tab as it still looking at your old tab.

log.click()
driver.switch_to.window(driver.window_handles[-1])
driver.execute_script('console.log(" lll kkk cheaky breeki ");')

Note that the tab switching is quite rudimentary, it simply goes to the last tab.

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