This is the site that I want to login into: https://nid.naver.com/nidlogin.login
When I tried to log in this site using selenium webdriver, it showed CAPTCHA.
But when I type id/pw by myself, keyboard typing, the CAPTCHA didn't show up!
How can selenium driver be detected?
It depends on your driver. Chromedriver does set specific js variables when it starts the browser. I'm sure other driver vendors have something similar. So, in short, yes. There are different ways it can determine that you are running via webdriver.
Related
I'm learning how selenium crawls data, but I find that when a website opens through selenium, it's different from what I used to get when I used other normal browsers. Even I add headers. And I'm very confused.
I really want to upload two contrast pictures, but I can't upload them in stackoverflow at present. I even tried to open the chrome driver and enter the web address manually, but the result is still different.
I use Python 3.6, selenium and chrome 75.0.3770.80
from selenium import webdriver
driver = webdriver.Chrome() #创建driver实例
url = 'https://www.free-ss.ooo'
driver.get(url)
At present, I can't post pictures on stack overflow, but I just want to figure out how I can use selenium to get normal web pages.
Aha,I found the problem, really because the target site detected selenium, the solution is to add options
Chrome_options. add_experiment_option ('excludeSwitches', ['enable-automation'])
Faced same issue and was able to resolve it by removing or fixing appropriate user-agent argument and it worked fine in both headless and non-headless mode.
The resolution was inspired by PDHide post
I am trying to get the actual user agent that I am using in Selenium, at the moment with the chromedriver.
I found a Java version of this problem:
How to get userAgent information in Selenium Web driver.
Does someone know how to do that in Python?
The same manner as inside your link:
user_agent = driver.execute_script("return navigator.userAgent;")
PS: Using execute_script method you can run JS inside your driver.
Hope it helps you!
Hi i want to use selenium to open Internet Explorer-11 as different user. I have done a search and it show that it is possible but with Java, I am using Python so I am wondering is it possible with Internet Explorer webdriver or not.
For example if you right click on internet explorer, it will have the part sign in as different user. I want to automate that part with python IE webdriver, but I do not know how to do it.
what I am asking is similar to this post How to impersonate a specific user with Selenium Webdriver?
but I want to do it in Python with selenium webdriver
To be clear. I know how to open the webrowser with selenium and i know how to sign in with selenium (when there is a pop up window). But I am asking about how to let selenium know that I want to sign in as different user. Because if I just open my browswer normally there is no pop up for sign in.
from selenium import webdriver
driver=webdriver.Ie()
Thank you
You can use Selenium Web Driver.
Learning about it you can do what you need with a code similar to this:
username = selenium.find_element_by_id("username")
password = selenium.find_element_by_id("password")
username.send_keys("YourUsername")
password.send_keys("yourPa55worD")
selenium.find_element_by_name("submit").click()
Since it seems you want to use another OS user, I suggest you use Sikuli:
Sikuli automates anything you see on the screen. It uses image recognition to identify and control GUI components. It is useful when there is no easy access to a GUI's internal or source code.
I think there is no way to do what you are wanting with just Selenium. If you need to integrate Selenium and Sikuli, you can see this post on SOF: Calling to a Sikuli script from Python (Selenium) . It can give some ideas for you.
I hope it helps.
Download IE Drivers based on your OS (Windows 32 or 64 bit)
a. Download
Windows 32 bits driver
OR
b. Download Windows 64 bits driver
Extract the zip and copy IEDriverServer.exe file to some location e.g. E:\IEDriver
Write the following script
from selenium import webdriver
browser = webdriver.Ie("e:\\IEDriver\\IEDriverServer.exe")
send values your inputs 'username' and 'password' and submit.
Run the script, it should open IE browser...
Is there a possibility if I code a program in python that allows to automatically browse a given website using mechanize to detect if there are popup windows (suggesting advertisements or downloading actions ...) using Python ?. I would appreciate any hint (for example, if you give me a library that fulfills this task I would be very happy)
Mechanize cannot handle javascript and popup windows:
How do I use Mechanize to process JavaScript?
Mechanize and Javascript
To accomplish the goal, you need to utilize a real browser, headless or not. This is where selenium would help. It has a built-in support for popup dialogs:
Selenium WebDriver has built-in support for handling popup dialog
boxes. After you’ve triggerd and action that would open a popup, you
can access the alert with the following:
alert = driver.switch_to_alert()
Example (using this jsfiddle):
from selenium import webdriver
url = "http://fiddle.jshell.net/ebkXh/show/"
driver = webdriver.Firefox()
driver.get(url)
button = driver.find_element_by_xpath('//button[#type="submit"]')
# dismiss
button.click()
driver.switch_to.alert.dismiss()
# accept
button.click()
driver.switch_to.alert.accept()
See also:
Handle Popup Windows
Click the javascript popup through webdriver
Unfortunately, Mechanize's browser seems to skip the pop-ups so the title, URL, and HTML are identical for both pop-ups and normal pages.
Frankly, Python is not the right tool for this job and is lagging behind in this respect IMHO. Having spent months doing web crawling, for sites that use Javascript extensively (the number of which is greatly increasing nowadays), I find that using Javascript-Based environments like PhantomJS or SlimerJS are simply better for what you're trying to do.
If you have the luxury to use Javascript-Based environments, I'd say go right ahead. However, you can still use python. PhantomJS embeds Ghost Driver. You can use Ghost.py to utilize the power of PhantomJS. Or you can use Selenium with Python as illustrated here.
Is there a possibility if I code a program in python that allows to automatically browse a given website using mechanize to detect if there are popup windows (suggesting advertisements or downloading actions ...) using Python ?. I would appreciate any hint (for example, if you give me a library that fulfills this task I would be very happy)
Mechanize cannot handle javascript and popup windows:
How do I use Mechanize to process JavaScript?
Mechanize and Javascript
To accomplish the goal, you need to utilize a real browser, headless or not. This is where selenium would help. It has a built-in support for popup dialogs:
Selenium WebDriver has built-in support for handling popup dialog
boxes. After you’ve triggerd and action that would open a popup, you
can access the alert with the following:
alert = driver.switch_to_alert()
Example (using this jsfiddle):
from selenium import webdriver
url = "http://fiddle.jshell.net/ebkXh/show/"
driver = webdriver.Firefox()
driver.get(url)
button = driver.find_element_by_xpath('//button[#type="submit"]')
# dismiss
button.click()
driver.switch_to.alert.dismiss()
# accept
button.click()
driver.switch_to.alert.accept()
See also:
Handle Popup Windows
Click the javascript popup through webdriver
Unfortunately, Mechanize's browser seems to skip the pop-ups so the title, URL, and HTML are identical for both pop-ups and normal pages.
Frankly, Python is not the right tool for this job and is lagging behind in this respect IMHO. Having spent months doing web crawling, for sites that use Javascript extensively (the number of which is greatly increasing nowadays), I find that using Javascript-Based environments like PhantomJS or SlimerJS are simply better for what you're trying to do.
If you have the luxury to use Javascript-Based environments, I'd say go right ahead. However, you can still use python. PhantomJS embeds Ghost Driver. You can use Ghost.py to utilize the power of PhantomJS. Or you can use Selenium with Python as illustrated here.