Control of Open window in a different test method

26 views
Skip to first unread message

Shyam Ramath

unread,
Feb 16, 2020, 8:37:21 AM2/16/20
to selenide
I'm new to selenide . I wrote two test-cases, while executing I see only the first test-case (userCanLoginByUsername()) working the second one did not get the handle of the page. What I'm I doing wrong here ? please advice



      @Test
public void userCanLoginByUsername()throws InterruptedException {
$(By.name("login_email")).setValue("user");
$(By.name("password")).setValue("pass");
$(By.className("btn")).click();
$(By.linkText("Academic Outcomes")).click();
}

@Test
public void testAdmissions()throws InterruptedException {
$(By.linkText("Admissions")).click();
Thread.sleep(3000);
$(By.linkText("Add New")).click();
Thread.sleep(5000);
}

Shyam Ramath

unread,
Feb 16, 2020, 8:44:06 AM2/16/20
to selenide
Element not found {By.linkText: Admissions}
Expected: visible or transparent: visible or have css value opacity=0
Screenshot: file:/T:/Code/Automation/colaradoierepository/ieautomation/build/reports/tests/1581860315031.0.png
Page source: file:/T:/Code/Automation/colaradoierepository/ieautomation/build/reports/tests/1581860315031.0.html
Timeout: 4 s.
Caused by: NoSuchElementException: no such element: Unable to locate element: {"method":"link text","selector":"Admissions"}
at com.codeborne.selenide.impl.WebElementSource.createElementNotFoundError(WebElementSource.java:37)
at com.codeborne.selenide.impl.ElementFinder.createElementNotFoundError(ElementFinder.java:100)
at com.codeborne.selenide.impl.WebElementSource.checkCondition(WebElementSource.java:65)
at com.codeborne.selenide.impl.WebElementSource.findAndAssertElementIsInteractable(WebElementSource.java:87)
at com.codeborne.selenide.commands.Click.execute(Click.java:13)
at com.codeborne.selenide.commands.Click.execute(Click.java:9)
at com.codeborne.selenide.commands.Commands.execute(Commands.java:145)
at com.codeborne.selenide.impl.SelenideElementProxy.dispatchAndRetry(SelenideElementProxy.java:99)
at com.codeborne.selenide.impl.SelenideElementProxy.invoke(SelenideElementProxy.java:65)
at com.sun.proxy.$Proxy5.click(Unknown Source)
at com.ie.automation.IELoginPageTest.testAdmissions(IELoginPageTest.java:30)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:567)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:89)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:542)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:770)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:464)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210)
Caused by: org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"link text","selector":"Admissions"}
  (Session info: chrome=79.0.3945.130)
For documentation on this error, please visit: https://www.seleniumhq.org/exceptions/no_such_element.html
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'SDM-AGN', ip: '10.141.10.116', os.name: 'Windows Server 2012 R2', os.arch: 'amd64', os.version: '6.3', java.version: '13.0.1'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities {acceptInsecureCerts: true, browserName: chrome, browserVersion: 79.0.3945.130, chrome: {chromedriverVersion: 79.0.3945.36 (3582db32b3389..., userDataDir: C:\Users\REGHUAMB\AppData\L...}, goog:chromeOptions: {debuggerAddress: localhost:51659}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: WINDOWS, platformName: WINDOWS, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify}
Session ID: b310b040d8e836d6bf619f2589ee012a
*** Element info: {Using=link text, value=Admissions}
at jdk.internal.reflect.GeneratedConstructorAccessor7.newInstance(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:323)
at org.openqa.selenium.remote.RemoteWebDriver.findElementByLinkText(RemoteWebDriver.java:380)
at org.openqa.selenium.By$ByLinkText.findElement(By.java:220)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:315)
at com.codeborne.selenide.impl.WebElementSelector.findElement(WebElementSelector.java:30)
at com.codeborne.selenide.impl.ElementFinder.getWebElement(ElementFinder.java:74)
at com.codeborne.selenide.impl.WebElementSource.checkCondition(WebElementSource.java:50)
... 32 more

Andrei Solntsev

unread,
Feb 16, 2020, 12:03:15 PM2/16/20
to Shyam Ramath, selenide
The error message seems absolutely clear to me. There is no link with text "Admissions".

--
You received this message because you are subscribed to the Google Groups "selenide" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenide+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenide/0177c7da-7a2f-4241-8f1c-e8df338c0873%40googlegroups.com.

Shyam Ramath

unread,
Feb 16, 2020, 1:12:08 PM2/16/20
to selenide
Yes you are right, but the page open in the browser . I want to write the test-case in mutiple methods, if you looks at the methods I shared it is failing at the second test-case . Is there a way to get the handle to the page in the second test-case ?


On Sunday, February 16, 2020 at 11:03:15 AM UTC-6, Andrei Solntsev wrote:
The error message seems absolutely clear to me. There is no link with text "Admissions".

To unsubscribe from this group and stop receiving emails from it, send an email to sele...@googlegroups.com.

Shyam Ramath

unread,
Feb 16, 2020, 1:21:10 PM2/16/20
to selenide
The same code works when add to the first test-case .

  @Test
public void userCanLoginByUsername()throws InterruptedException {
$(By.name("login_email")).setValue("user");
$(By.name("password")).setValue("pass");
$(By.className("btn")).click();
$(By.linkText("Academic Outcomes")).click();

                 $(By.linkText("Admissions")).click();
Thread.sleep(3000);
$(By.linkText("Add New")).click();
Thread.sleep(5000);
}


On Sunday, February 16, 2020 at 11:03:15 AM UTC-6, Andrei Solntsev wrote:
The error message seems absolutely clear to me. There is no link with text "Admissions".

To unsubscribe from this group and stop receiving emails from it, send an email to sele...@googlegroups.com.

Andrei Solntsev

unread,
Mar 14, 2020, 5:20:40 AM3/14/20
to Shyam Ramath, selenide
How do you open the browser? 
I guess you should move this line to @Before method. 

Andrei Solntsev


вс, 16 февр. 2020 г. в 20:21, Shyam Ramath <shyam....@gmail.com>:
To unsubscribe from this group and stop receiving emails from it, send an email to selenide+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenide/a5b0f5d6-176f-4035-bf1c-7371e3316044%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages