Cant submit Captcha textfield in python selenium
Hello everyone,
I want to submit a textfield which is filled with the Code for Captcha, but I can't submit it.
This is the Error:
Exception has occurred: NoSuchElementException
Message: Unable to locate element: ./ancestor-or-self::form
enter image description here
This is my script(it works perfectly on other webpages):
sub = driver.find_element_by_class_name("g-recaptcha-response")
sub.submit()
have tried also a lot of other things, but nothing worked.
Here the HTML-Code:
enter image description here
The Textfield is that in the whole bottom.
I would be very happy, if someone can help me. Thank you for you time!
Ps: This is my first Question, so sorry, if I did something wrong. And I am not from the USA or England, so my English is a bit bad...
The reason this error occurs is that you are trying to find a specific element before it is rendered.
To put it simply, the web page is not ready yet, but it is a problem that occurs when you try to scrape information.
sub = driver.find_element_by_class_name("g-recaptcha-response")
sub.submit()
Edit it!
From official Selenium documentation:
CAPTCHA, short for Completely Automated Public Turing test to tell Computers and Humans Apart, is explicitly designed to prevent automation, so do not try!
What you could do instead is
Disable CAPTCHAs in your test environment
Add a hook to allow tests to bypass the CAPTCHA
Related
I have a problem with bypass Arkoselabs Funcaptcha with selenium on Twitter page.
I cant submit token because there is not any submit button.
When I try to paste token and just click random pictures I get wrong answer error.
I also tried to solve captchas by getting captcha picture and instructions, request something like 2captcha and click on images. It worked before, but now there is new type of captcha with arrows. When I did the same things I just get wrong answer from 2captcha.
Do you know what should I do?
c# code. Similar to this in Python
var captchaToken = "3084f4a302b176cd7.96368058|r=ap-southeast-1|guitextcolor=%23FDD531|......";
((IJavaScriptExecutor)chrome).ExecuteScript("parent.postMessage(JSON.stringify({eventId:'challenge-complete',payload:{sessionToken:'" + captchaToken + "'}}),'*')");
I'm new in python scripting. I'm trying to develop a bot that can access websites and work on it with Selenium.
I can do basics things like enter text in a search bar but I am blocked with a popup.
I try to access the popup element but I can't. It seems the element I want to reach are on a "modal" popup.
I have tried many things, I can access to the "modal"popup:
popup = self.__driver.find_element_by_xpath("//div[#id='modal']")
but I can't access to any element right under the revious one:
element = self.__driver.find_element_by_xpath("//div[#id='region-modal-right-panel']")
Can somebody help me with this problem? Thank you in advance for your help!!
If my explanations wasn't clear, do not hesitate to ask for mor details.
EDIT: link to the popup: https://app.libertex.com/products/currency/EURUSD/#modal_newInvest_EURUSD
Using selenium I can browse through the entire website except for the login screen on a specific website. When I checked page source I see some js codes.
Using a normal chrome browser I can access the expected login screen. Can anyone help me to overcome this issue? Thanks in advance.
Chances are that the website is detecting that you are using a bot and is blocking you from accessing its login screen for that reason. I can't know for sure that this is the reason because I haven't seen your issue in person, but most good websites don't like having non-human users interact with their pages, and a login page is exactly the type of page that the website would block you from accessing.
You can try to change some things to make Selenium less detectable by the website, but it's quite difficult and inconsistent at best. You can find some more information about achieving this here, but I wouldn't expect too much.
I try to login a site automatically by selenium.
My script sometimes works smoothly but sometimes it does not send full-text of user name or passwork to relavant inputs so it then failed to login.
I try to insert implicitly_wait but it appears not to solve this problem totally.
I wonder if there is any function to require the webdriver to fullfill each of input before excecute another one in selenium.
Here is may attempt:
browserdriver.get(url)
#fill username
browserdriver.implicitly_wait(25)
psusername=browserdriver.find_element_by_xpath("//*[#class='form-group'][1]/input[#name='username']")
psusername.click()
psusername.send_keys("1234567890")
#fill password
browserdriver.implicitly_wait(25)
pspass=browserdriver.find_element_by_xpath("//*[#class='form-group'][2]/input[#name='password']")
pspass.click()
pspass.send_keys("abcdefgfk12345")
browserdriver.implicitly_wait(25)
pssubmit=browserdriver.find_element_by_xpath("//*[#class='login-btn']/button[#type='submit']")
pssubmit.click()
Pls, explain for me why I get stuck on this problem and how to solve it! thanks alot
EDIT1: I add the target site address: click here You should click on login words (Đăng nhập) on the top right screen to see the popup login pannel.
EDIT 2: Thank to guide of below comments, I try to add some code lines to force it to key individual letter and it appears to work well so I add solution here:
text_input="1234567890"
for i in text_input:
psusername.send_keys(i)
Use set attribute instead of sendkeys
here is the example code:
webdriver.executeScript("document.getElementById('elementID').setAttribute('value', '1234567890')");
Question: yikyak.com returns some sort of "browser not supported" landing page when I try to view source code in chrome (even for the page I'm logged in on) or when I write it out to the Python terminal. Why is this and what can I do to get around it?
Edit for clarification: I'm using the chrome webdriver. I can navigate around the yik yak website by clicking on it just fine. But whenever I try to see what html is on the page, I get an html page for a "browser not reported" page.
Background: I'm trying to access yikyak.com with selenium for python to download yaks and do fun things with them. I know fairly little about web programming.
Thanks!
Secondary, less important question: If you're already here, are there particularly great free resources for a super-quick intro to the certification knowledge I need to store logins and stuff like that to use my logged in account? That would be awesome.
I figured it out. I was being dumb. I saved off the html as a file and opened that file with chrome and it displayed the normal page. I just didn't see the fact that it was a normal page looking at it directly. Thanks all 15 people for your time.