C# Immediately after creating webdriver I get the message "no such window: target window already closed"
Windows 10 Selenium 3.141.0 Selenium Chrome Driver 87.0.4280.2000
driver = new ChromeDriver();
driver.Manage().Window.Maximize();
driver.Navigate().GoToUrl("https://www.google.com");
Thread.Sleep(5000);
driver.Quit();
driver.Dispose();
After the driver = new ChromeDriver();
is when I get the message.
This is being run in a Console Application for testing.
This is the full message:
OpenQA.Selenium.NoSuchWindowException: no such window: target window already closed
from unknown error: web view not found
(Session info: chrome=87.0.4280.66)
at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
at OpenQA.Selenium.Remote.RemoteWebDriver.set_Url(String value)
at OpenQA.Selenium.Remote.RemoteNavigator.GoToUrl(String url)
at WebDriverTest.Program.Main(String[] args) in C:\Source\Visual Studio\@POC\WebDriverTest\Program.cs:line 42
See also questions close to this topic
-
The problem with setting up IIS UrlRewrite rules for ASP.NET Core 3.1 after migration
I am trying to do a migration for the ASP.NET Core Web Application from 2.2 to 3.1. The frontend app for the application is
Angular
. This is the workingasp.net core 2.2
piece of code fromStartup.cs
:public void Configure(IApplicationBuilder app, IHostingEnvironment env) { //... app.UseCors(x => x.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader()); app.UseAuthentication(); ConfigureUrlRewriting(app, env); ConfigureRouting(app); } private static void ConfigureUrlRewriting(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment() && File.Exists("IISUrlRewrite.xml")) { using (var reader = File.OpenText("IISUrlRewrite.xml")) { var options = new RewriteOptions().AddIISUrlRewrite(reader); app.UseRewriter(options); } } } private static void ConfigureRouting(IApplicationBuilder app) { app.UseDefaultFiles(new DefaultFilesOptions { DefaultFileNames = new List<string> { "index.html" } }); app.UseStaticFiles(); app.UseMvc(routes => { routes.MapRoute(name: "default", template: "api/{controller}/{id}"); }); }
After migration to asp.net core 3.1 following the guide from Microsoft docs the code changed like:
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { //... app.UseCors(x => x.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader()); app.UseAuthentication(); ConfigureUrlRewriting(app, env); ConfigureRouting(app); } private static void ConfigureUrlRewriting(IApplicationBuilder app, IHostEnvironment env) { if (env.IsDevelopment() && File.Exists("IISUrlRewrite.xml")) { using (var reader = File.OpenText("IISUrlRewrite.xml")) { var options = new RewriteOptions().AddIISUrlRewrite(reader); app.UseRewriter(options); } } } private static void ConfigureRouting(IApplicationBuilder app) { app.UseDefaultFiles(new DefaultFilesOptions { DefaultFileNames = new List<string> { "index.html" } }); app.UseStaticFiles(); // Changed only the lines below app.UseRouting(); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute(name: "default", pattern: "api/{controller}/{id}"); }); }
After deploying on IIS local server there is the problem that all requests for static files returns
index.html
Here's the proof:Here's the content of
IISUrlRewrite.xml
:<rewrite> <rules> <rule name="AngularJS Routes" stopProcessing="true"> <match url=".*" /> <conditions logicalGrouping="MatchAll"> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> <add input="{REQUEST_URI}" pattern="^/(api)/" negate="true" /> </conditions> <action type="Rewrite" url="/" /> </rule> </rules> </rewrite>
Seems like the condition
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
is not matched for the static files. But the condition is mathed when the app isasp.net core 2.2
Can someone explain please this behaviour after migration? Is it the problem of
.net core
code or IIS-side problems? -
Error, platform-specific implementation not set // AdColony Unity
I was Trying to implement Adcolony into my unity project and this error has appeared. I hope someone can help me. The variables are:
string[] zoneIds = new string[] { "vz150fd4742f8f4281a1", "vz3bea056c072d437287" }; string APP_ID = "appbdca0d68df44424f90"; AdColony.AppOptions options = new AdColony.AppOptions();
My Start() function is :
private void Start() { Debug.Log(APP_ID); Debug.Log(zoneIds[0]+" "+zoneIds[1]); if (Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer) { AdColony.Ads.Configure(APP_ID, null, zoneIds); } }
My OnMouseDown() function is :
public void OnMouseDown() { AdColony.AdOptions adOptions = new AdColony.AdOptions(); adOptions.ShowPrePopup = false; adOptions.ShowPostPopup = false; AdColony.Ads.RequestInterstitialAd(zoneIds[0], adOptions); AdColony.Ads.OnRequestInterstitial += (AdColony.InterstitialAd ad) => { StartCoroutine(addAds()); gameObject.GetComponent<Collider2D>().enabled = true; gameObject.GetComponent<Animator>().enabled = true; todayEarnings.enabled = true; totalEarnings.enabled = true; Destroy(Loading); }; AdColony.Ads.OnExpiring += (AdColony.InterstitialAd ad) => { AdColony.Ads.RequestInterstitialAd(ad.ZoneId, adOptions); }; AdColony.Ads.OnRewardGranted += (string zoneId, bool success, string name, int amount) => { SceneManager.LoadScene("playScene1"); }; AdColony.Ads.OnRequestInterstitialFailed += () => { SceneManager.LoadScene("playScene1"); }; AdColony.Ads.OnOpened += (AdColony.InterstitialAd ad) => { StartCoroutine(addAds()); gameObject.GetComponent<Collider2D>().enabled = true; gameObject.GetComponent<Animator>().enabled = true; todayEarnings.enabled = true; totalEarnings.enabled = true; Destroy(Loading); }; AdColony.Ads.OnClosed += (AdColony.InterstitialAd ad) => { SceneManager.LoadScene("playScene1"); }; }
The error is :
Error, platform-specific implementation not set UnityEngine.Debug:LogError(Object) AdColony.Ads:get_SharedInstance() (at Assets/AdColony/Scripts/AdColony.cs:299) AdColony.Ads:IsSupportedOnCurrentPlatform() (at Assets/AdColony/Scripts/AdColony.cs:308) AdColony.Ads:IsInitialized() (at Assets/AdColony/Scripts/AdColony.cs:317) AdColony.Ads:RequestInterstitialAd(String, AdOptions) (at Assets/AdColony/Scripts/AdColony.cs:53) gotoPlayScene:OnMouseDown() (at Assets/Scripts/homeScripts/gotoPlayScene.cs:83) UnityEngine.SendMouseEvents:DoSendMouseEvents(Int32)
-
Unload Event firing on Page Loading in Asp.net
I wanted to fire unload event when page is close or close browser tab / window. I have used below code but it is firing when page it load instead of page unload. I have used master / child page concept in asp.net
Partial Class test Inherits System.Web.UI.Page Dim dbconn As Object = New DBConnection() Private Sub test_Unload(sender As Object, e As EventArgs) Handles Me.Unload dbconn.OpenConnection() Dim cmd As SqlCommand = New SqlCommand("UPDATE test SET abc = '2' where sno = '123'", dbconn.con) cmd.CommandType = CommandType.Text cmd.ExecuteNonQuery() dbconn.CloseConnection() End Sub End Class
-
Can not find file that is in resource folder - java
I have a question regarding file handling. I automate a page using selenium, and I need to upload a file in this page. I want to put the file in resource folder and read it's path in the test (since many OS and path will be different to any computer WIN/MAC).
I put the file manually in the resource folder, and it put it in:
X:\Project_11_01_2021\src\test\resources
when I used the ClassLoader and try to find the file it not found it, I saw that if I manually put it in this path it find it, found.
X:\Project_11_01_2021\out\test\resources
the problem is that I am using git and if I add to the resources it upload to git and every one will get the change, and when I put in out\test\resources it is not displayed in the source tree to commit to git. is their a way that classLoader will search in the first location? and not in the second?
[
][path that worked]
[
][when here not worked]
/******* test *******/
public void entertax() throws Exception { WebDriver deiver2 = getWebDriver(); Thread.sleep(1000); ClassLoader classLoader = getClass().getClassLoader(); String path = classLoader.getResource("TAX12.pdf").getPath(); System.out.println("\n\n path is " + path); deiver2.switchTo() .activeElement(); deiver2.findElement(By.xpath("//input[@type='file']")) .sendKeys( "X:\\Project_11_01_2021\\out\\test\\resources\\fw8TAX12.pdf"); System.out.println("END"); }
-
Can not get file path from resource folder - Java
I try to automate a page that I have. In the page I need to upload a PDF file. The problem is that I want selenium via java will get the file from the resource of the project and not hard coded. (since some have windows and some mac and some ubonto so the solution is to get the path dynamically).
I manually hard coded I enter the path it worked and return the path, however to let java return the path it crash. this is my code:
/******* test *******/ public void testFileUpload() throws Exception { WebDriver deiver2 = getWebDriver(); Thread.sleep(3000); deiver2.switchTo() .activeElement(); deiver2.findElement(By.xpath("//input[@type='file']")) .sendKeys( "X:\\project\\src\\test\\resources\\TAX12.pdf"); ClassLoader classLoader = getClass().getClassLoader(); String path = classLoader.getResource("TAX12.pdf").getPath(); System.out.println("\n\n path is " + path); System.out.println("END"); }
I want in the send keys to send the file, the exists however it is not worked. get null exception
the file exists in the folder and worked if manually set the path, but not locate the file if I want it to do it by himself (for win / mac / linux etc)
-
Can not get file path from resource folder - Java (exception)
I try to automate a page that I have. In the page I need to upload a PDF file. The problem is that I want selenium via java will get the file from the resource of the project and not hard coded. (since some have windows and some mac and some ubonto so the solution is to get the path dynamically).
I manually hard coded I enter the path it worked and return the path, however to let java return the path it crash. this is my code:
/******* test *******/ public void testFileUpload() throws Exception { WebDriver deiver2 = getWebDriver(); Thread.sleep(3000); deiver2.switchTo() .activeElement(); deiver2.findElement(By.xpath("//input[@type='file']")) .sendKeys( "X:\\project\\src\\test\\resources\\TAX12.pdf"); ClassLoader classLoader = getClass().getClassLoader(); String path = classLoader.getResource("TAX12.pdf").getPath(); System.out.println("\n\n path is " + path); System.out.println("END"); }
I want in the send keys to send the file, the exists however it is not worked.
java.lang.NullPointerException at org.testng.Assert.fail(Assert.java:97) at tests.ExPubPaymentPageTest.tryFile(ExPubPaymentPageTest.java:58) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:134) at org.testng.internal.TestInvoker.invokeMethod(TestInvoker.java:597) at org.testng.internal.TestInvoker.invokeTestMethod(TestInvoker.java:173) at org.testng.internal.MethodRunner.runInSequence(MethodRunner.java:46) at org.testng.internal.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:816) at org.testng.internal.TestInvoker.invokeTestMethods(TestInvoker.java:146) at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:146) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:128) at java.util.ArrayList.forEach(ArrayList.java:1259) at org.testng.TestRunner.privateRun(TestRunner.java:766) at org.testng.TestRunner.run(TestRunner.java:587) at org.testng.SuiteRunner.runTest(SuiteRunner.java:384) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:378) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:337) at org.testng.SuiteRunner.run(SuiteRunner.java:286) at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53) at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96) at org.testng.TestNG.runSuitesSequentially(TestNG.java:1187) at org.testng.TestNG.runSuitesLocally(TestNG.java:1109) at org.testng.TestNG.runSuites(TestNG.java:1039) at org.testng.TestNG.run(TestNG.java:1007) at com.intellij.rt.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:66) at com.intellij.rt.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:109)
the file exists in the folder and worked if manually set the path, but not locate the file if I want it to do it by himself (for win / mac / linux etc)