Can not accept javascript alert after latest google chrome updates - selenium-webdriver

I use webdriver for my Ui tests.
After latest google chrome updates like 44.0.2403.107 I have problems with accepting alerts:
I use driver.SwitchTo().Alert().Accept(); when I confirm javascript alert, I get exception: no alert open. It looks like alert opens later than I try accept it. Does anybody else have the same problem after latest google chrome updates?
I use latest version chromedriver - 2.16.

Did you tried to include wait for alert as shown below:
new WebDriverWait(driver,60).until(ExpectedConditions.alertIsPresent());
driver.switchTo().alert().accept();
If you still facing issue please raise issue at below URL with sample test code and html file included:
https://code.google.com/p/chromedriver/issues/list

Related

unclear (for me) error on loading url using chrome webdriver in selenium

I had a working python script to do some basic data scraping from a local IP address using selenium and chromedriver. The working version used the executable path to define where chromedriver.exe was.
I had to change this as it stopped working (wouldn't load chrome anymore, chromedriver version definitely correct) so swapped the path to a service object.
My script now opens chrome again, but gets hung up with 'data:,' in the address bar, until it times out (after 1 minute exactly) and an error message 'selenium.common.exceptions.WebDriverException: Message: unknown error: DevToolsActivePort file doesn't exist'
Sidenote - a new bug I've noticed since changing this: if I have a chrome window open already, the script opens a new tab with url 'data:,' nut without the little bar saying chrome is being controlled by automated software, and I get an error saying 'selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited normally.'
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import Select
from webdriver_manager.chrome import ChromeDriverManager
s = Service(path to folder "chromedriver.exe")
url = "http://the page i'm after"
driver = webdriver.Chrome(service=s)
driver.get(url)`
after this, the script fills in a form, hits submit and does a bit of scraping. But currently it just gets stuck with a url of 'data:,' and times out after a minute and then I get the error - 'selenium.common.exceptions.WebDriverException: Message: unknown error: DevToolsActivePort file doesn't exist'
It was working a few days ago and I can't think of anything that changed on the site I'm using or anything else!
I think there are unnecessary imports, but I've tried a few things and got a bit lost...
Thanks a lot for any help or tips, I'm pretty new to coding in general, so was very quickly out of ideas
EDIT, running with chrome options "--headless" there is no problem. Can anyone explain why this works?

CEF Sharp remote debugging with chrome not working after chrome update(80.0.3987.116)

My Hybrid application created using WPF, CEFShaprp, and VueJS.
The CEF remote debugging was working correctly till chrome version 79.0.3945.130.
Upgraded to new chrome version (80.0.3987.116).
Once we do remote debugging when we hit URL in the browser it's identifying the web apps.
but on selection, it's redirecting to a blank page and in the console, we can see the below error.
Uncaught TypeError: document.registerElement is not a function at Object.UI.registerCustomElement
Please let me know anyone faced this issue?
any workaround to fix this issue?
any help will be appreciated.

Selenium: execute script after Google Tag Manager has loaded

I'm loading a URL in selenium, which uses Google Tag Manager to inject a script.
<script src="http://sample.com/file.js" />
I'm loading the URL in the webdriver using this
await driver.get('https://sample-page-that-uses-gtm.com)
When I go to that URL in my browser (not selenium driver), and manually check the script in the elements tab and console (query selector), I can successfully find the script. However, this is not the case in Selenium. I manually opened console of the Selenium Webdriver and ran a check for the presence of the injected script, but there was none detected.
This is what I ran on the console
document.querySelector('script[src="http://sample.com/file.js"]')
It finds the script on the browser, but not on Webdriver. Is this a problem with using GTM on Selenium?
try to use an expected condition to force the code to wait before checking if the script is present:
WebDriverWait(browser, 3).until(EC.element_to_be_clickable((By.XPATH, "//script[#src='http://sample.com/file.js']")))
this might be happening because you're checking for the script before it gets loaded in the DOM, if this does not solve your problem, please update your question with an example of a URL that uses Google Tag Manager and doesn't load on selenium, as this will help identify the problem

How to show console.log() in code in Terminal from web extension firefox?

In Web extension Firefox :
How to show or enable console.log() in my code in the terminal , I used "we-ext run -v" command but it show logs of web extension framework not my logs in my code ?
Are you sure your setup is right? For me, console.log() messages are shown in both, browser console and web console.

Timeout::Error: timeout while waiting for angular with Capybara + rails

I have an integration test that is failing for the reason:
"Timeout::Error: timeout while waiting for angular"
I have run the test with selenium so that I can see what happens, and the page loads perfectly fine. I threw a debugger in my test so that I can browse around the app with the test fixtures-- and everything works perfectly...
Yet in the debugger, as soon as I type "page", to query what capybara thinks it sees, I get:
[5] pry(#<RSpec::Core::ExampleGroup::Nested_1>)> page
Timeout::Error: timeout while waiting for angular
from /Users/me/.rvm/gems/ruby-2.0.0-p451#my_app/gems/capybara-angular-0.0.4/lib/capybara/angular/waiter.rb:30:in `timeout!'
So basically it's lying to me because angular is fully loaded, api calls are happening and responding with json, the templates are getting interpolated... What the... ?
This gem has been updated to 0.1.0, which fixes the problem you are describing. Cheers!
Issue & Pull Request: https://github.com/wrozka/capybara-angular/issues/11

Resources