Timeout Error while using selenium firefox webdriver in VBA - excel

I am trying to use selenium firefox webdriver to navigate to a page and initiate a click event. This event should paste a csv data onto the clipboard. Upon executing this code the firefox window pops up without any url in the address bar and then I get the following error message:
Error: TimeoutError
Firefox failed to open the listening port 127.0.0.1:12825 with 15s
Here is my code
Set objFireFox = CreateObject("Selenium.FirefoxDriver")
objFireFox.Get "https://chartink.com/screener/practical-swing-trading-stock-scanner", 20000, False
objFireFox.FindElementsByClass("btn btn-default buttons-copy buttons-html5 btn-primary").Click
Initially I was using the following statement
objFireFox.Get "https://chartink.com/screener/practical-swing-trading-stock-scanner"
then I modified it to
objFireFox.Get "https://chartink.com/screener/practical-swing-trading-stock-scanner", 20000, False
but still the error message was same in both cases. I have downloaded the latest version of mozilla/geckodriver from https://github.com/mozilla/geckodriver/releases/tag/v0.30.0
Thanks

Related

Playwright fails to fill input

I'm running a Playwright script on a Jenkins page that has input elements. When I try to fill one of the inputs with text, it fails with this error:
(node:3337) UnhandledPromiseRejectionWarning: page.fill: Protocol error (Page.insertText): error in channel "content::page": exception while running method "insertText" in namespace "page": Component returned failure code: 0xc1f30001 (NS_ERROR_NOT_INITIALIZED) [nsITextInputProcessor.commitCompositionWith] _insertText#chrome://juggler/content/content/PageAgent.js:891:32
I've tried running with DEBUG=pw:api environment enabled but the logs there aren't too helpful. From the normal console log I get the following log:
waiting for selector "input[name="_.buildNumber"]"
selector resolved to visible <input value="" type="text" name="_.buildNumber" class=…/>
elementHandle.fill("54")
waiting for element to be visible, enabled and editable
element is visible, enabled and editable
So it seems like the element exists and can be edited but for some reason Playwright is unsuccessful at trying to fill it. What am I missing here?
This is a Playwright bug that is specific to Firefox. To get around it for now, you should be able to switch to using either Chrome or Safari in your import statement. So either:
import { chromium } from 'playwright';
Or using Safari:
import { webkit } from 'playwright';

elementIsNotVisible throwing noSuchElementError in Selenium

I wrote a test to ensure a slideout panel closes in my selenium tests using node js. Whenever I close the panel I use the condition elementIsNotVisible. However an error is thrown, noSuchElementError. This error is technically correct because the element should no longer be on the page, but shouldn't elementIsNotVisible be correct as well?
Test.js file:
await driver.wait(until.elementIsVisible(testPage.addAllAnnotationsButton(driver)), 20000);
await testPage.exitGeneAnnotationsButton(driver).click();
await driver.wait(until.elementIsNotVisible(testPage.addAllAnnotationsButton(driver)), 20000);
Page.js file:
const testPage = {
addAllAnnotationsButton: driver => driver.findElement(By.css(testPage.addAllAnnotationsButtonSELECTOR))
}
Error message(Note- Error message is thrown on the line where elementIsNotVisible is called):
NoSuchElementError: no such element: Unable to locate element: {"method":"css selector","selector":"div.slideout.opened:nth-child(6) button.ui.button.medium:nth-child(2)"}
Edit 1: Please note, I have tried using stalenessOf and I still receive the same error.
As you have mentioned that when you close the panel, you use the condition elementIsNotVisible :
Here once you have closed the panel , the respective web element is not present in DOM. That is the reason you are getting NoSuchElement exception.
Suggestion : Use invisiblityofElement instead of elementIsNotVisible.
Though there are many reasons behind NoSuchElement Exception, one of the most common is try to interact with element/elements present in frame/iframe without switching the focus of web driver.
Hope this will help.

Python Selenium : How to stop Auto Refreshing of Internal Elements of a Webpage in Selenium?

I want to automate mail checking on temp-mail.org
But the problem is the page keeps on refreshing internal components of page and therefore Selenium can't target mail.
My code:
mail= browser.find_element_by_xpath('//tbody/tr/td[#title="__mail title__"]')
mail.click()
But there is no response.
Then I noticed that contents of page are auto refreshing internally.
So how to stop this auto refreshing?
How about stopping the script aftre 3/5 secs of its runtime.
Try this :
fire = webdriver.FirefoxProfile()
fire.set_preference("http.response.timeout", 3)
fire.set_preference("dom.max_script_run_time", 3)
driver = webdriver.Firefox(firefox_profile=fire)
driver.get("url")

Chrome alert pop up not detected in Selenium

I am having issues with handling Authentication pop up in Chrome via Selenium.
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
driver = webdriver.Chrome()
driver.get('URL')
time.sleep(5)
alert = driver.switch_to_alert()
alert.send_keys('Username')
alert.send_keys(Keys.TAB)
alert.send_keys('Password')
This returns an error--
"selenium.common.exceptions.NoAlertPresentException: Message: no alert open"
Alternatively, I also tried the following code:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
driver = webdriver.Chrome()
driver.get('https://Username:Password#URL')
The second code works partially-
In Chrome the user is logged in but the page does not load. Only a blank page is displayed. Once the blank page is loaded, i passed only the URL(without user credentials) and it works fine.
In Firefox, the webpage loads perfectly.
Basically, the issue is with Chrome.
Any help is appreciated.
Thanks!
The second code you have tried is correct with a slight mistake.
public void loginToSystem(String username,String password, String url){
driver = webdriver.Chrome()
driver.get("https://"+username+":"+password+"# "+URL);
}
First try to wait for alert present.
wait = WebDriverWait(driver, 10)
wait.until(EC.alert_is_present())
if alert is present then only move forword to next step.
And also can you please check the screenshot if alert is actually present when testcase is failing.

Watir: "unexpected alert open" error thrown when trying to refresh page after manually closing alert

I've created an instance of Watir::Browser with chrome set as the browser.
b = Watir::Browser.new :chrome
If I manually close an alert and then try to refresh the page using
b.refresh
the following error is thrown:
Selenium::WebDriver::Error::UnhandledAlertError: unexpected alert open
(Session info: chrome=28.0.1500.95)
(Driver info: chromedriver=2.2,platform=Windows NT 6.1 x86_64)
from C:/ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.35.0/lib/selenium/webdriver/remote/response.rb:51:in assert_ok'
from C:/ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.35.0/lib/selenium/webdriver/remote/response.rb:15:in initialize'
from C:/ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.35.0/lib/selenium/webdriver/remote/http/common.rb:59:in new'
from C:/ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.35.0/lib/selenium/webdriver/remote/http/common.rb:59:in create_response'
from C:/ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.35.0/lib/selenium/webdriver/remote/http/default.rb:66:in request'
from C:/ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.35.0/lib/selenium/webdriver/remote/http/common.rb:40:in call'
from C:/ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.35.0/lib/selenium/webdriver/remote/bridge.rb:634:in raw_execute'
from C:/ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.35.0/lib/selenium/webdriver/remote/bridge.rb:612:in execute'
from C:/ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.35.0/lib/selenium/webdriver/remote/bridge.rb:210:in refresh'
from C:/ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.35.0/lib/selenium/webdriver/common/navigation.rb:38:in refresh'
from C:/ruby193/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.6.4/lib/watir-webdriver/browser.rb:201:in refresh'
When I call b.alert.exists? it returns true.
I tried looking at using b.alert.initialize to reset the state of the alert but it throwns an exception.
Is there a way to completely reset the state of the browser object?
I was facing this problem too:
But I am successfully get rid of it by putting it in a begin-rescue block.
Here is how:
begin
# put line of code which triggers alert on page
rescue Selenium::WebDriver::Error::UnhandledAlertError
#browser.alert.ok
end

Resources