Using JavaScript in Selenium command is revoked by Windows security settings
Asked Answered
V

0

0

I'm automating a web page with selenium-python where there's a hidden JavaScript button. The HTML is this:

<script type="text/javascript"> add_itemtitle("Restart"); </script><div class="content_item_title">Restart</div>
<div class="maintenance_item">
<div class="maintenance_item_desc">
Click <b>Restart</b> to restart device
</div>
<div class="maintenance_item_butt">
<script language="JavaScript" type="text/javascript">
create_button("Restart","btnReboot");
</script><span class="button_wrapper" id="btnReboot"><span class="button_left"><span class="button_right"><span class="button_center">Restart</span></span></span></span>
</div>
</div>

I have been using following codes but it didn't worked for me.

WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, '//*[@id="btnReboot"]'))).click()

and execute_script

"""working with javascript buttton """
#1
#element=WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//a[text()[contains(.,'Restart')]]")))    
#driver.execute_script("arguments[0].click();", element)
#2
#element=WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//span[text()='Restart']"))).click()
#driver.execute_script("arguments[0].click();", element)
#3
#submit_button = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//a[text()[contains(.,'submitButton')]]")))    
#driver.execute_script("arguments[0].click();", submit_button)

leads to Virus&theart protection Virus&theart protection

Controlled folder access blocked chromedriver.exe from making changes.ckick to see setting.

is there any selenium option like following to evade the Virus&theart protection

options.add_argument("start-maximized")
#disable security content
options.add_argument('--ignore-ssl-errors=yes')
options.add_argument('--ignore-certificate-errors')
options.add_argument('--allow-insecure-localhost')
Vinegarish answered 22/11, 2022 at 6:18 Comment(8)
chromedriver injects a dll. This is likely what's causing the warning. You probably need to whitelist chromedriver.exe.Cerulean
The thing that's complaining is "Windows Security", a part of Windows. I would suggest searching "windows 10 security whitelist"Cerulean
You don't avoid it. The injection is required in order for Selenium to work.Cerulean
can it be solved by using options like options.add_argument('--ignore-ssl-errors=yes'), I am not admin in my computerVinegarish
No. It has to do with Windows security settings. If you're not an administrator on that computer, you won't be able to use Selenium on that computer.Cerulean
@Cerulean I appreciate your time and dedication for solving my issues.Vinegarish
@Vinegarish I saw this your question when you asked it, but unfortunately I don't know how to help here. It's not something I ever faced with. I'm sorry :(Unitarian
Maybe Debanjan will be able to help. stackoverflow.com/users/7429447/undetected-seleniumUnitarian

© 2022 - 2024 — McMap. All rights reserved.