How to kill thread in a Selenium Grid node

前端 未结 1 531
盖世英雄少女心
盖世英雄少女心 2021-01-26 09:27

I am running a code in Selenium Grid. I have a class named TestBase as follows and I want to quit all the threads when I click on a button,but when I click on the button a Nullp

1条回答
  •  被撕碎了的回忆
    2021-01-26 09:37

    Personally, I wouldn't use ThreadLocal . I would just use protected member variables, having protected WebDriver being a member of a TestBase class. Then, once your session is started on the grid, make your test remember the session ID, then if there is an error, you can kill the Grid thread by sending a command to quit the driver along with the session id for that thread. I would basically be a JSON request. JSON wire protocol has a delete command that looks like this:

    DELETE /session/:sessionId
    

    By using ThreadLocal, in my opinion you are using something that is meant to handle local threads and trying to apply that concept to a remote service that has its own thread handling in it already. I guess I never use ThreadLocal because my testrunner does the thread forking for me: TestNG.

    0 讨论(0)
提交回复
热议问题