selenium ERROR :policy_loader_win.cc - python

I encounter an ERROR when I use selenium to login a website.
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver=webdriver.Chrome(executable_path='C:/ProgramFiles/Google/Chrome/Application/chromedriver.exe')
driver.get("http://bbs.pinggu.org/member.php?mod=logging&action=login")
login_name=driver.find_element_by_name("username")
login_name.clear()
login_name.send_keys("") ##this is login name. omit
login_name.send_keys(Keys.RETURN)
login_pass=driver.find_element_by_name("password")
login_pass.clear()
login_pass.send_keys("") ##this is login password. omit
login_pass.send_keys(Keys.RETURN)
login=driver.find_element_by_name('loginsubmit')
login.send_keys(Keys.RETURN)
driver.close()
I get an ERROR:
[9492:8552:0918/152646:ERROR:policy_loader_win.cc(449)]PReg file doesn't exist:C:\WINDOWS\System32\GroupPolicy\User\Registry.pol
I search some item, but I don't know to use it.
https://gitlab.com/fancycode/iridium-browser/blob/75a646c6596597e9c21659187fe75bbd68c2c2b9/components/policy/core/common/policy_loader_win.cc

Related

Why is this Xpath not working with selenium?

I'm trying to input an email address to test logging in, but I'm continuing to receive this error: no such element: Unable to locate element:
I have tried using the relative and absolute Xpath and receive the same error message.
Forgive me as I'm sure missing something simple, very new to this!
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
import time
driver = webdriver.Chrome()
url = 'https://soundcloud.com/signin'
driver.get(url)
time.sleep(2)
driver.find_element_by_xpath('//*[#id="sign_in_up_email"]').send_keys('test#test.com')
The reason its throwing error is because the element sign_in_up_email is present inside the iframe
Refer image
Check the link here for detail about how to switch to iframe
You will first need to switch to iframe and then enter value in the input
Note:- When you first open the page you might see the accept cookies popup from soundcloud you will have to accept that
Your solution would look like
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
import time
driver = webdriver.Chrome()
url = 'https://soundcloud.com/signin'
driver.get(url)
driver.maximize_window()
time.sleep(2)
# Accept cookie
driver.find_element_by_id('onetrust-accept-btn-handler').click()
# Switch to frame
driver.switch_to.frame(driver.find_element_by_class_name("webAuthContainer__iframe"))
driver.find_element_by_xpath('//*[#id="sign_in_up_email"]').send_keys('test#test.com')

Press Enter on URL in address bar with Selenium

I am running a script with Selenium that loops over a number of URLs. However, some URLs give a 503 service error. For example the following code gives me such an error.
import requests
import selenium
from selenium import webdriver
url = 'https://destyy.com/q3P5W7'
driver = webdriver.Chrome()
driver.get(url)
response = requests.get(driver.current_url).status_code
I tried refreshing the browser in the case of an error, but then the error persists.
if response == 503:
driver.refresh()
I noticed that if I manually select the url in the address bar of my driver and press enter, the page loads to the desired location. I tried to write this into code but it fails:
from selenium.webdriver.common.keys import Keys
address_bar = driver.find_element_by_xpath('/html/body').send_keys(Keys.CONTROL, "l")
address_bar.sendKeys(Keys.ENTER)
Please help me out. How can I load the page? Thanks in advance,

Python Selenium unable to login by clicking on Button inside a form

website: https://www.etoro.com/login
I am trying to click on Sign in button by xpath :
Code trial:
driver.find_element_by_xpath("/html/body/ui-layout/div/div/div[1]/login/login-sts/div/div/div[1]/form/div/div[4]/button").click()
But failed to do so. Tried by css and by class also but unable to login.
When I am trying to login manually then it login successfully but while through selenium python it failed to do so.
Page only showing an error: "An error occurred ,please try again" Is there any suggestions, what to do or what I am not getting here?
<button automation-id="login-sts-btn-sign-in" ng-click="loginCtrl.login(loginForm)" class="e-btn-big wide dark pointer">Sign in</button>
driver.find_element_by_xpath("/html/body/ui-layout/div/div/div[1]/login/login-sts/div/div/div[1]/form/div/div[4]/button").click()
Expected result would be a successfull login and render to the dashboard of my account.
To send a character sequence to a Username and Password field's, and also invoke a click() on an element with text as Sign in as value ,you need to induce a WebDriverWait for the element to be clickable and after that you will be able to use the following solution:
Code Block:
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
driver= webdriver.Firefox(executable_path=r'C:\Utility\BrowserDrivers\geckodriver.exe')
driver.get("https://www.etoro.com/login")
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "input.w-login-main-form-input.ng-valid-email.ng-invalid-required.ng-valid-pattern"))).send_keys("Etoro")
driver.find_element_by_css_selector("input.w-login-main-form-input[type='password']").send_keys("Test")
driver.find_element_by_css_selector("button.e-btn-big.wide.dark.pointer[automation-id='login-sts-btn-sign-in']").click()
Browser Snapshot:
You need to install chromedriver and chrome. You can change these settings for other browsers if you want. This work fine for me.
My OS: Ubuntu 16.04
from selenium import webdriver
browser = webdriver.Chrome("/usr/lib/chromium-browser/chromedriver")
browser.get('<login_url>')
username = browser.find_element_by_name("<username_name_tag>")
password = browser.find_element_by_name("<password_name_tag>")
username.send_keys("<username>")
password.send_keys("<password>")
browser.find_element_by_xpath("//button[#automation-id='login-sts-btn-sign-in' and #value='Sign in']").click()

Inconsistent results when using selenium and when manually clicking

I am trying to automate logging into my salesforce account. When I use my code:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
browser= webdriver.Firefox()
browser.get("https://xxxxx.my.salesforce.com/?
SAMLRequest=&startURL=%2Fidp%2Flogin%3Fapp%
3D0sp0g000000Gmhj&un=xxxxx.xxxxx%40xxxxx.com")
elem=browser.find_element_by_id("username")
elem.send_keys("xxxxx.xxxx#xxxxx.com")
elem_pass=browser.find_element_by_id("password")
elem_pass.send_keys("xxxxxxx")
rem_me=browser.find_element_by_id("rememberUn")
rem_me.click()
elem.send_keys(Keys.ENTER)
As you can see, I pass the link to the url, pass the usname, password and remember me.
When I run this with Selenium, it goes to a email 2FA authentication page.
But when I do it manually:
Copy the url mentioned above.
Paste it into the address bar of firefox browser.
The uname and pass show already populated.
When I hit enter, it logs me in. (No 2FA).
Is Salesforce somehow detecting that request is from selenium?
And is there a way to get around it?
Could this be related to this?
Different results when using Selenium + Python
Yup, I got it resolved. I had to import cookies from Firefox, and use them with Selenium. from selenium import webdriver from selenium.webdriver.common.keys import Keys import os os.chdir("C:\Users\tsingh\Desktop\Cookies") ffprofile = webdriver.FirefoxProfile('C:\Users\tsingh\Desktop\Cookies') browser = webdriver.Firefox(firefox_profile=ffprofile)

Open another page after logging in using selenium webdriver

I am using selenium webdriver to open a page in my website using python.
The page link is : "www.example.com/App/Details.aspx/I=5aM%+8KbCv1o=&T=M30Lr7RtcdR=&H=fRFKse5fKA=="
Since I cannot open this page directly, I have to first login on
www.example.com, which I am doing this way:
from selenium.common.exceptions import TimeoutException
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Firefox()
try:
driver.set_page_load_timeout(10)
driver.get('http://www.example.com')
except Exception:
print ('time out')
#driver.find_element_by_id("Default").send_keys(Keys.CONTROL +'Escape')
username = driver.find_element_by_id("usrid")
password = driver.find_element_by_id("pswd")
username.send_keys("Sample_user")
password.send_keys("samplepass")
driver.find_element_by_id("submitbtn").click()
After this I am am able to log in successfully,
but when I redirect to the above link using
driver.get("www.example.com/App/Details.aspx/I=5aM%+8KbCv1o=&T=M30Lr7RtcdR=&H=fRFKse5fKA==")
I get error saying please login first. Please suggest a solution for the same.
You sent the data via
password.send_keys
but after that you were to also send enter command using
password.send_keys((Keys.ENTER)
After this you have to have a
sleep(1)
or
WebDriverWait Until(expect...
before you open the next page

Categories

Resources