- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
**出现以下异常:org.openqa.selenium.NoSuchSessionException: session ID 为空。调用 quit() 后使用 WebDriver?在这里,我使用 LocalThread 进行并行测试执行,但是在一个线程中的类中运行多个测试时(不是并行执行)第一个测试用例成功运行,第二个和第三个测试用例失败**
Console Output:
[TestNG] Running:
C:\Users\Afsar\AppData\Local\Temp\testng-eclipse--442788521\testng-customsuite.xml
****** In Before Method init method *********
Driver instanceis created and set current local thread
Starting ChromeDriver 2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f) on port 41879
Only local connections are allowed.
log4j:WARN No appenders could be found for logger (org.apache.http.client.protocol.RequestAddCookies).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Oct 22, 2017 5:03:12 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
Set current thread method is called ..
Get curent thread method is called ..
Current thread id :1 thread name is :main
Get curent thread method is called ..
Current thread id :1 thread name is :main
Get curent thread method is called ..
Current thread id :1 thread name is :main
*********Running first Test Case *********
Get curent thread method is called ..
Current thread id :1 thread name is :main
Get curent thread method is called ..
Current thread id :1 thread name is :main
**** Executing Logine Action *********
URL is sent succesfully..
Clicked on the Sign -on button
User name Entered
Password entered
Sign -in clicked
****** Executing Register Action *********
Get curent thread method is called ..
Current thread id :1 thread name is :main
Register button is found
PASSED : First test case : Login Successful..
****** In After Method tear down *********
Removing driver instance from current thread and closing all sesions
driver.quite called
****** In Before Method init method *********
Driver instanceis created and set current local thread
Starting ChromeDriver 2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f) on port 47720
Only local connections are allowed.
Oct 22, 2017 5:03:39 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
Set current thread method is called ..
Get curent thread method is called ..
Current thread id :1 thread name is :main
Get curent thread method is called ..
Current thread id :1 thread name is :main
Get curent thread method is called ..
Current thread id :1 thread name is :main
*********Running second Test Case *********
**** Executing Logine Action *********
URL is sent succesfully..
****** In After Method tear down *********
Removing driver instance from current thread and closing all sesions
driver.quite called
****** In Before Method init method *********
Driver instanceis created and set current local thread
Starting ChromeDriver 2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f) on port 25049
Only local connections are allowed.
Oct 22, 2017 5:03:45 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
Set current thread method is called ..
Get curent thread method is called ..
Current thread id :1 thread name is :main
Get curent thread method is called ..
Current thread id :1 thread name is :main
Get curent thread method is called ..
Current thread id :1 thread name is :main
*********Running third Test Case *********
**** Executing Logine Action *********
URL is sent succesfully..
****** In After Method tear down *********
Removing driver instance from current thread and closing all sesions
driver.quite called
Current thread removed and clearcurrentDriver() called.. ..
PASSED: LoginFunctionality
This is first test same as first
FAILED: LoginFunctionality1
This is second test same as first
org.openqa.selenium.NoSuchSessionException: Session ID is null. Using WebDriver after calling quit()?
Build info: version: '3.6.0', revision: '6fbf3ec767', time: '2017-09-27T15:28:36.4Z'
System info: host: 'AFSAR-PC', ip: '192.168.0.100', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_131'
Driver info: driver.version: RemoteWebDriver
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:131)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:586)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:356)
at org.openqa.selenium.remote.RemoteWebDriver.findElementByLinkText(RemoteWebDriver.java:410)
at org.openqa.selenium.By$ByLinkText.findElement(By.java:246)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:348)
at org.openqa.selenium.support.pagefactory.DefaultElementLocator.findElement(DefaultElementLocator.java:69)
at org.openqa.selenium.support.pagefactory.internal.LocatingElementHandler.invoke(LocatingElementHandler.java:38)
at com.sun.proxy.$Proxy9.click(Unknown Source)
at com.afsar.framework.pageobjects.MercuryToursHomePage.clickRegister(MercuryToursHomePage.java:58)
at com.afsar.framework.actions.MercuryHomePage_Action.Login_Action(MercuryHomePage_Action.java:13)
at com.afsar.framework.tests.LoginTest.LoginFunctionality1(LoginTest.java:56)
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:80)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
at org.testng.TestRunner.privateRun(TestRunner.java:767)
at org.testng.TestRunner.run(TestRunner.java:617)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
at org.testng.SuiteRunner.run(SuiteRunner.java:240)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1198)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1123)
at org.testng.TestNG.run(TestNG.java:1031)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:230)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:76)
FAILED: LoginFunctionality2
This is third test same as first
org.openqa.selenium.NoSuchSessionException: Session ID is null. Using WebDriver after calling quit()?
Build info: version: '3.6.0', revision: '6fbf3ec767', time: '2017-09-27T15:28:36.4Z'
System info: host: 'AFSAR-PC', ip: '192.168.0.100', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_131'
Driver info: driver.version: RemoteWebDriver
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:131)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:586)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:356)
at org.openqa.selenium.remote.RemoteWebDriver.findElementByLinkText(RemoteWebDriver.java:410)
at org.openqa.selenium.By$ByLinkText.findElement(By.java:246)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:348)
at org.openqa.selenium.support.pagefactory.DefaultElementLocator.findElement(DefaultElementLocator.java:69)
at org.openqa.selenium.support.pagefactory.internal.LocatingElementHandler.invoke(LocatingElementHandler.java:38)
at com.sun.proxy.$Proxy9.click(Unknown Source)
at com.afsar.framework.pageobjects.MercuryToursHomePage.clickRegister(MercuryToursHomePage.java:58)
at com.afsar.framework.actions.MercuryHomePage_Action.Login_Action(MercuryHomePage_Action.java:13)
at com.afsar.framework.tests.LoginTest.LoginFunctionality2(LoginTest.java:67)
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:80)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
at org.testng.TestRunner.privateRun(TestRunner.java:767)
at org.testng.TestRunner.run(TestRunner.java:617)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
at org.testng.SuiteRunner.run(SuiteRunner.java:240)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1198)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1123)
at org.testng.TestNG.run(TestNG.java:1031)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:230)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:76)
===============================================
Default test
Tests run: 3, Failures: 2, Skips: 0
===============================================
===============================================
Default suite
Total tests run: 3, Failures: 2, Skips: 0
===============================================
[TestNG] Time taken by org.testng.reporters.XMLReporter@49e4cb85: 407 ms
[TestNG] Time taken by org.testng.reporters.EmailableReporter@5594a1b5: 75 ms
[TestNG] Time taken by org.testng.reporters.JUnitReportReporter@6e8dacdf: 19 ms
[TestNG] Time taken by org.testng.reporters.SuiteHTMLReporter@1134affc: 373 ms
[TestNG] Time taken by [FailedReporter passed=0 failed=0 skipped=0]: 27 ms
[TestNG] Time taken by org.testng.reporters.jq.Main@2f7c7260: 118 ms
Login Test :
public class LoginTest{
private WebDriver driver;
@BeforeMethod
@Parameters("BROWSER")
public void init(@Optional("Chrome")String BROWSER) throws Exception{
System.out.println("****** In Before Method init method *********");
System.out.println("Driver instanceis created and set current local thread");
//Opening desired Browser driver instance
driver=DriverFactory.OpenBrowser(BROWSER);
//Setting Current driver with threadLocal
Driver.setCurrentDriver(driver);
Driver.getCurrentDriver().manage().window().maximize();
Driver.getCurrentDriver().manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
//This is Baseclass constructor (Initializaton)
new BaseClass(Driver.getCurrentDriver());
}
@Test(description="This is first test same as first ")
public void LoginFunctionality() throws Exception{
System.out.println("*********Running first Test Case *********");
MercuryHomePage_Action.Login_Action();
MercuryHomePage_Action.Register_Action();
System.out.println("PASSED : First test case : Login Successful..");
}
@Test(description="This is second test same as first ")
public void LoginFunctionality1() throws Exception{
System.out.println("*********Running second Test Case *********");
MercuryHomePage_Action.Login_Action();
MercuryHomePage_Action.Register_Action();
System.out.println("PASSED : second test case : Login Successful..");
}
@Test(description="This is third test same as first ")
public void LoginFunctionality2() throws Exception{
System.out.println("*********Running third Test Case *********");
MercuryHomePage_Action.Login_Action();
MercuryHomePage_Action.Register_Action();
System.out.println("PASSED : third test case : Login Successful..");
}
@AfterMethod
public void teardown(){
System.out.println("****** In After Method tear down *********");
System.out.println("Removing driver instance from current thread and closing all sesions");
//Driver.getCurrentDriver().quit();
Driver.QuitDriver();
}
@AfterTest
public void aftertest(){
Driver.clearCurrentDriver();
}
}
Driver Factory Class:
public class DriverFactory {
//private static WebDriver driver;
//@Parameters("BROWSER")
public static WebDriver OpenBrowser(String BROWSER) throws Exception{
WebDriver driver=null;
try{
if(BROWSER.equals("Mozilla")){
driver = new FirefoxDriver();
Log.info("New driver instantiated");
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
Log.info("Implicit wait applied on the driver for 10 seconds");
//driver.get(Constant.URL);
Log.info("Web application launched successfully");
}else if(BROWSER.equalsIgnoreCase("Chrome")){
System.setProperty("webdriver.chrome.driver", "C:\\Users\\Afsar\\git\\HybridFramework_POM\\HybridFramework\\Drivers\\chromedriver.exe");
driver = new ChromeDriver();
Log.info("New driver instantiated");
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
Log.info("Implicit wait applied on the driver for 10 seconds");
//driver.get(Constant.URL);
Log.info("Web application launched successfully");
}
}catch (Exception e){
Log.error("Class Utils | Method OpenBrowser | Exception desc : "+e.getMessage());
}
return driver;
}
Driver class:
private static ThreadLocal<WebDriver> CURRENT_DRIVER = new ThreadLocal<>();
public static WebDriver getCurrentDriver() {
System.out.println("Get curent thread method is called ..");
Long callingThreadID = new Long(Thread.currentThread().getId());
System.out.println("Current thread id :"+callingThreadID +" thread name is :"+Thread.currentThread().getName());
return CURRENT_DRIVER.get();
}
public static void setCurrentDriver(WebDriver driver) {
System.out.println("Set current thread method is called ..");
CURRENT_DRIVER.set(driver);
}
public static void clearCurrentDriver() {
System.out.println("Current thread removed and clearcurrentDriver() called.. ..");
if (CURRENT_DRIVER.get() != null) {
CURRENT_DRIVER.get().quit();
CURRENT_DRIVER.remove();
}
CURRENT_DRIVER.remove();
}
public static void QuitDriver() {
System.out.println("driver.quite called ");
if (CURRENT_DRIVER.get() != null) {
CURRENT_DRIVER.get().quit();
//CURRENT_DRIVER.remove();
}
//CURRENT_DRIVER.remove();
}
*请在这种情况下帮助我,您可以在 GitHub 存储库中找到该项目: https://github.com/afsarali273/HybridFramework_POM *
最佳答案
问题是,在运行第一个测试时会调用 driver.quit() ,因为在 After 方法注释中, driver.quit() 在第一个测试用例之后被调用。这样,第二个和第三个测试用例的驱动程序为空。使用下面的代码。它会工作得很好:)
@AfterMethod
public void teardown(){
System.out.println("****** In After Method tear down *********");
System.out.println("Removing driver instance from current thread and closing all sesions");
//Driver.getCurrentDriver().quit();
}
@AfterTest
public void aftertest(){
Driver.QuitDriver();
}
关于java - 获取异常 : selenium. NoSuchSessionException : Session ID is null. 这里我使用 Localthread<webdriver> 进行并行执行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46873803/
是否为每个 Shiny session 分配了 session ID/ session key (如果部署在 Shiny 服务器上)?如果是,我如何访问该信息?我已阅读文档here然而上网查了一下,并
我正在使用 this koajs session 模块。 我检查了源代码,但我真的无法理解。 我想知道它保存 session 数据的位置,因为我没有看到创建的文件,并且当服务器重新启动时, sessi
实现高可扩展性的一种方法是使用网络负载平衡在多个服务器之间分配处理负载。 这种方法提出的一个挑战是服务器是否具有状态意识 - 将用户状态存储在“ session ”中。 此问题的一个解决方案是“粘性
在负载平衡服务器的上下文中, session 亲和性和粘性 session 之间有什么区别? 最佳答案 我见过这些术语可以互换使用,但有不同的实现方式: 在第一个响应中发送 cookie,然后在后续响
我希望其他人向我解释哪种方法更好:使用 session 或设计无 session 。我们正在开始开发一个新的 Web 应用程序,但尚未决定要遵循什么路径。 无 session 设计在我看来更可取: 优
现在用户在他的权限中有很多角色,我将允许他点击 href 并在新窗口中扮演另一个角色。每个角色都有自己的 session 。 既然浏览器打开窗口不能用新 session 打开,我必须在服务器端想办法。
我正在尝试为express.js Node 应用程序实现 session 存储我的问题是: 如何删除具有浏览器 session 生命周期的 cookie(根据连接文档标记有 expires = fal
在开始在 golang 中使用 session 之前,我需要回答一些问题 session 示例 import "github.com/gorilla/sessions" var store = ses
我读过 Namespaced Attributes . 我尝试使用此功能: #src/Controller/CartController.php public function addProduct(
我正在努力完成以下工作: 根据用户的类型更改用户的 session cookie 到期日期。 我有一个 CakePHP Web 应用程序,其中我使用 CakePHP session 创建了我的身份验证
这是我在这里的第一个问题,我希望我做对了。 我需要处理一个 Java EE 项目,所以在开始之前,我会尝试做一些简单的事情,看看我是否能做到。 我坚持使用有状态 session Bean。 这是问题:
ColdFusion session 与 J2EE session 相比有什么优势吗? ColdFusion session documentation提到了 J2EE session 的优点,但没有
在执行任何任务之前,我需要准确地在创建 session 时创建一个 session 范围变量(因为我的所有任务都需要一个初始 session 范围变量才能运行)。因为,创建 session 时,gra
我们当前的应用使用 HTTP session ,我们希望将其替换为 JWT。 该设置仅允许每个用户进行一次 session 。这意味着: 用户在设备 1 上登录 用户已在设备 1 上登录(已创建新 s
很难说出这里问的是什么。这个问题是含糊的、模糊的、不完整的、过于宽泛的或修辞性的,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开它,visit the help center 。 已关
假设我在两个或更多设备上打开了两个或更多用户 session (同一用户没有管理员权限)。 在当前 session 中,如果我注销,是否意味着所有其他 session 也会关闭?如果没有,有没有办法通
我正在评估在 tomcat 中使用带有 session 复制的粘性 session 的情况。根据我的初步评估,我认为如果我们启用 session 复制,那么在一个 tomcat 节点中启动的 sess
我开始使用 golang 和 Angular2 构建一个常规的网络应用程序,最重要的是我试图在 auth0.com 的帮助下保护我的登录.我从 here 下载快速入门代码并尝试运行代码,它运行了一段时
我在 Spring Controller 中有一个方法,它接受两个相同类型的参数其中一个来自 session ,另一个来自表单提交(UI)。 问题是在 Controller 方法中我的非 sessio
在我登录之前,我可以点击我的安全约束目录之外的任何内容。如果我尝试转到安全约束目录内的某个位置,它会将我重定向到表单登录页面。如您所料。 登录后,我可以继续我的业务,并访问我的安全约束内外的资源。
我是一名优秀的程序员,十分优秀!