selenium.common.exceptions.WebDriverException: Message: target frame detached - selenium

every now and then this error appears when I launch my script. It doesn't happen all the time, I often only need to run the script again to not get this message anymore.
What could be the problem?
Traceback (most recent call last):
File "C:\Python\Python310\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 927, in page_source
return self.execute(Command.GET_PAGE_SOURCE)['value']
File "C:\Python\Python310\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 425, in execute
self.error_handler.check_response(response)
File "C:\Python\Python310\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 247, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: target frame detached
(Session info: chrome=100.0.4896.127)
Stacktrace:
Backtrace:
Ordinal0 [0x00EC9943+2595139]
Ordinal0 [0x00E5C9F1+2148849]
Ordinal0 [0x00D543F0+1065968]
Ordinal0 [0x00D45A97+1006231]
Ordinal0 [0x00D44AD0+1002192]
Ordinal0 [0x00D450D8+1003736]
Ordinal0 [0x00D45068+1003624]
Ordinal0 [0x00D4B220+1028640]
Ordinal0 [0x00D462AD+1008301]
Ordinal0 [0x00D467C5+1009605]
Ordinal0 [0x00D465AF+1009071]
Ordinal0 [0x00D45BC6+1006534]
Ordinal0 [0x00D4542B+1004587]
Ordinal0 [0x00D452C9+1004233]
Ordinal0 [0x00D558A0+1071264]
Ordinal0 [0x00DAB3BB+1422267]
Ordinal0 [0x00D9B806+1357830]
Ordinal0 [0x00D76086+1204358]
Ordinal0 [0x00D76F96+1208214]
GetHandleVerifier [0x0106B232+1658114]
GetHandleVerifier [0x0112312C+2411516]
GetHandleVerifier [0x00F5F261+560433]
GetHandleVerifier [0x00F5E366+556598]
Ordinal0 [0x00E6286B+2173035]
Ordinal0 [0x00E675F8+2192888]
Ordinal0 [0x00E676E5+2193125]
Ordinal0 [0x00E711FC+2232828]
BaseThreadInitThunk [0x76A1FA29+25]
RtlGetAppContainerNamedObjectPath [0x77007A7E+286]
RtlGetAppContainerNamedObjectPath [0x77007A4E+238]

Try to check that:
Selenium is upgraded to the latest available version
ChromeDriver and Chrome Browser are updated to the latest available version
Or, if you use Firefox, check that GeckoDriver and Firefox Browser are updated to the latest available version

Related

Selenium return error without detailed info about error. How to identify error?

When I run my Selenium/Python script it shows the following error, which has no typical error info attached (ie. NoSuchElementException,...). All I got is the following output:
**Stacktrace:
Backtrace:
Ordinal0 [0x0045ACD3+2075859]
Ordinal0 [0x003EEE61+1633889]
Ordinal0 [0x002EB7BD+571325]
Ordinal0 [0x0031AC2F+764975]
Ordinal0 [0x0031AE1B+765467]
Ordinal0 [0x0034D0F2+970994]
Ordinal0 [0x00337364+881508]
Ordinal0 [0x0034B56A+963946]
Ordinal0 [0x00337136+880950]
Ordinal0 [0x0030FEFD+720637]
Ordinal0 [0x00310F3F+724799]
GetHandleVerifier [0x0070EED2+2769538]
GetHandleVerifier [0x00700D95+2711877]
GetHandleVerifier [0x004EA03A+521194]
GetHandleVerifier [0x004E8DA0+516432]
Ordinal0 [0x003F682C+1665068]
Ordinal0 [0x003FB128+1683752]
Ordinal0 [0x003FB215+1683989]
Ordinal0 [0x00406484+1729668]
BaseThreadInitThunk [0x76316939+25]
RtlGetFullPathName_UEx [0x77C98FD2+1218]
RtlGetFullPathName_UEx [0x77C98F9D+1165]**
I use
try:
#code goes here
except Exception as e:
print(str(s))
How to detect where and why the error occures as ordirar try/except does not help much?
One way to catch the error is to do:
try:
#code goes here
except Exception as e:
error_msg = ''.join(traceback.format_exception(type(e), e, e.__traceback__))
print(error_msg)

unknown error: cannot determine loading status error using chrome=104.0.5112.81 with Cucumber and Selenium::WebDriver

Does anyone know why this error is occurring during a selenium test?
I'm switching from page during the test. I have also noticed that when a test don't switch page it behaves normally, and the test passed.
unknown error: cannot determine loading status
from unknown error: unexpected command response
(Session info: chrome=104.0.5112.81) (Selenium::WebDriver::Error::UnknownError)
Backtrace:
Ordinal0 [0x00C96463+2188387]
Ordinal0 [0x00C2E461+1762401]
Ordinal0 [0x00B43D78+802168]
Ordinal0 [0x00B37210+750096]
Ordinal0 [0x00B3675A+747354]
Ordinal0 [0x00B35D3F+744767]
Ordinal0 [0x00B34C28+740392]
Ordinal0 [0x00B35228+741928]
Ordinal0 [0x00B3EF2F+782127]
Ordinal0 [0x00B49FBB+827323]
Ordinal0 [0x00B4D310+840464]
Ordinal0 [0x00B354F6+742646]
Ordinal0 [0x00B49BF3+826355]
Ordinal0 [0x00B9CF6D+1167213]
Ordinal0 [0x00B8C5F6+1099254]
Ordinal0 [0x00B66BE0+945120]
Ordinal0 [0x00B67AD6+948950]
GetHandleVerifier [0x00F371F2+2712546]
GetHandleVerifier [0x00F2886D+2652765]
GetHandleVerifier [0x00D2002A+520730]
GetHandleVerifier [0x00D1EE06+516086]
Ordinal0 [0x00C3468B+1787531]
Ordinal0 [0x00C38E88+1805960]
Ordinal0 [0x00C38F75+1806197]
Ordinal0 [0x00C41DF1+1842673]
BaseThreadInitThunk [0x76AEFA29+25]
RtlGetAppContainerNamedObjectPath [0x77CC7A9E+286]
RtlGetAppContainerNamedObjectPath [0x77CC7A6E+238]
This error message...
unknown error: cannot determine loading status
from unknown error: unexpected command response
(Session info: chrome=104.0.5112.81) (Selenium::WebDriver::Error::UnknownError)
Backtrace:
.
.
RtlGetAppContainerNamedObjectPath [0x77CC7A9E+286]
RtlGetAppContainerNamedObjectPath [0x77CC7A6E+238]
...implies that there is some mismatch between the chromedriver and the chrome versions.
Solution
As you are using chrome=104.0.5112.81 ensure that you have download chromedriver=104.0.5112.79 and using the same.

selenium.WebDriverException: chrome not reachable

I have a C++ application application.exe, which uses a CEF browser (chrome embedded framework) as the UI.
For this UI I want to develop automated tests with Selenium. Usually I control Selenium via Java.
below is the stack trace I'm getting:
Starting ChromeDriver 91.0.4472.101 (af52a90bf87030dd1523486a1cd3ae25c5d76c9b-refs/branch-heads/4472#{#1462}) on port 36815
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
org.openqa.selenium.WebDriverException: chrome not reachable
Build info: version: '3.13.0', revision: '2f0d292', time: '2018-06-25T15:24:21.231Z'
System info: host: 'NO1010042072000', ip: '10.42.72.0', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '15.0.2'
Driver info: driver.version: ChromeDriver
remote stacktrace: Backtrace:
Ordinal0 [0x006C3733+2504499]
Ordinal0 [0x0065C401+2081793]
Ordinal0 [0x005624F0+1058032]
Ordinal0 [0x005574B5+1012917]
Ordinal0 [0x0058005B+1179739]
Ordinal0 [0x0057C58C+1164684]
Ordinal0 [0x00579DC3+1154499]
Ordinal0 [0x005A9B82+1350530]
Ordinal0 [0x005A97DA+1349594]
Ordinal0 [0x005A5D4B+1334603]
Ordinal0 [0x005822B4+1188532]
Ordinal0 [0x00583149+1192265]
GetHandleVerifier [0x0083FB8C+1512252]
GetHandleVerifier [0x008EB0DF+2214031]
GetHandleVerifier [0x00744BC3+484211]
GetHandleVerifier [0x00743E69+480793]
Ordinal0 [0x0066218D+2105741]
Ordinal0 [0x006666E8+2123496]
Ordinal0 [0x00666827+2123815]
Ordinal0 [0x0066FB73+2161523]
BaseThreadInitThunk [0x74EAFA29+25]
RtlGetAppContainerNamedObjectPath [0x77037C7E+286]
RtlGetAppContainerNamedObjectPath [0x77037C4E+238]
My code snippet:
System.setProperty("webdriver.chrome.driver", "C:\\Users\\Administrator\\Desktop\\chromedriver_win32\\chromedriver.exe");
 
ChromeOptions options = new ChromeOptions();
options.setBinary(<cef_workflow_path>);
WebDriver chDriver = new ChromeDriver(options);
 
 
 
sleep(3000);
chDriver.findElement(By.id("EmailPage-EmailField"));
WebElement email = chDriver.findElement(By.id("EmailPage-EmailField"));
System.out.println(email.isDisplayed());
email.clear();
email.sendKeys(userName);
I see you truing to access web element on the web page before you passed an URL to the driver.
You need first to
chDriver.get(yourURLLink);
and only after that, when the page is loaded try accessing the elements with
chDriver.findElement(By.id("EmailPage-EmailField"));
etc.
Can you check with this, I hope it will work for you
ChromeOptions option = new ChromeOptions();
option.addArguments(new ArrayList<String>() {
{
add("--no-sandbox");
add("--disable-gpu-sandbox");
}
});
WebDriver driver = new ChromeDriver(option);

Selenium MSEdge - open the IE mode in Edge without DevToolsActivePort error being thrown

MSEdgeDriver and browser version used 88.0.705.63 (64 bit).
Works when provided with edge options.addArguments("--headless") or with-remote-debugging-port ; but when we remove -remote-debugging-port,DevToolsActivePort error is thrown as shwon below.
With -remote-debugging-port, the site is not opened with Internet Explorer mode. Is there any way we can open the IE mode in Edge and not get DevToolsActivePort error
Message: org.openqa.selenium.WebDriverException: unknown error: DevToolsActivePort file doesn't exist
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'A036T0L6347NRVX', ip: '10.227.221.75', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_66'
Driver info: driver.version: EdgeDriver
remote stacktrace: Backtrace:
Ordinal0 [0x00007FF6D6D0AF92+241554]
GetHandleVerifier [0x00007FF6D747CA88+2173368]
GetHandleVerifier [0x00007FF6D749FAC8+2316792]
GetHandleVerifier [0x00007FF6D7499BC9+2292473]
GetHandleVerifier [0x00007FF6D74CB760+2496144]
GetHandleVerifier [0x00007FF6D74C7A5F+2480527]
GetHandleVerifier [0x00007FF6D74A550A+2339898]
GetHandleVerifier [0x00007FF6D74A614B+2343035]
Ordinal0 [0x00007FF6D6CE2D01+77057]

org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: error message is displayed while running parallel execution

org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: error message is displayed while running parallel execution after configuring --remote-debugging-port=9222 chrome option. How to fix this issue ?
Note : (unknown error: DevToolsActivePort file doesn't exist) error message is displayed if it is not configured --remote-debugging-port=9222 chrome option, so I have added remote debugging port in chrome options
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setPageLoadStrategy(PageLoadStrategy.NONE);
chromeOptions.addArguments("--no-sandbox");
chromeOptions.addArguments("--start-maximized");
chromeOptions.addArguments("--no-sandbox");
chromeOptions.addArguments("--disable-infobars");
chromeOptions.addArguments("--disable-dev-shm-usage");
chromeOptions.addArguments("--disable-browser-side-navigation");
chromeOptions.addArguments("--disable-gpu");
chromeOptions.addArguments("--disable-notifications");
chromeOptions.addArguments("--remote-debugging-port=9222");
chromeOptions.addArguments("--disable-extensions");
chromeOptions.setExperimentalOption("useAutomationExtension", false);
chromeOptions.addArguments("allow-running-insecure-content");
chromeOptions.addArguments("--ignore-certificate-errors");
driver = new ChromeDriver(chromeOptions);
Error message :
org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: crashed.
(The process started from chrome location C:\Program Files (x86)\Google\Chrome\Application\chrome.exe is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
Build info: version: '3.14.0', revision: 'aacccce0', time: '2018-08-02T20:19:58.91Z'
System info: host: 'fffffff', ip: 'xyz', os.name: 'Windows Server 2016', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_231'
Driver info: driver.version: ChromeDriver
remote stacktrace: Backtrace:
Ordinal0 [0x00B30C83+1707139]
Ordinal0 [0x00A968F1+1075441]
Ordinal0 [0x00A0DFC9+516041]
Ordinal0 [0x0099D373+54131]
Ordinal0 [0x009BBFD7+180183]
Ordinal0 [0x009BBDDD+179677]
Ordinal0 [0x009B9D4B+171339]
Ordinal0 [0x009A1D4A+73034]
Ordinal0 [0x009A2DC0+77248]
Ordinal0 [0x009A2D59+77145]
Ordinal0 [0x00AABB67+1162087]
GetHandleVerifier [0x00BCA966+508998]
GetHandleVerifier [0x00BCA6A4+508292]
GetHandleVerifier [0x00BDF7B7+594583]
GetHandleVerifier [0x00BCB1D6+511158]
Ordinal0 [0x00AA402C+1130540]
Ordinal0 [0x00AAD4CB+1168587]
Ordinal0 [0x00AAD633+1168947]
Ordinal0 [0x00AC5B35+1268533]
BaseThreadInitThunk [0x770362C4+36]
RtlSubscribeWnfStateChangeNotification [0x77411E39+1081]
RtlSubscribeWnfStateChangeNotification [0x77411E04+1028]
--remote-debugging-port=9222
this option is used when you are trying to run your tests on chrome browser which is already running on this port 9222
and same is error message which says chrome.exe is not running
org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: crashed.
(The process started from chrome location C:\Program Files (x86)\Google\Chrome\Application\chrome.exe is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
So see your test case what it is doing, I believe you are trying to capture already running chrome node registered with grid.
so this might also required
cp.setExperimentalOption("debuggerAddress", "127.0.0.1:9222");
Full working example here
start chrome browser using command
C:\Program Files (x86)\Google\Chrome\Application>chrome.exe --remote-debugging-port=9222 --user-data-dir="C:\autoprofile"
The code to connect the browser is :-
package com.example;
import org.openqa.selenium.By;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
public class ChromeDebugger {
public static void main(String[] args) throws InterruptedException {
ChromeOptions cp = new ChromeOptions();
cp.setExperimentalOption("debuggerAddress", "127.0.0.1:9222");
System.setProperty("webdriver.chrome.driver",
"./src/test/resources/drivers/chromedriver.exe");
ChromeDriver driver = new ChromeDriver(cp);
System.out.println(driver.getTitle());
driver.findElement(By.linkText("About")).click();
System.out.println(driver.getTitle());
}
}