I'm testing the application contains a ton of table, which is currently in need of parsing I'm currently using The method which is slow for very large tables, so I thought I can try multi-thread and get those elements simultaneously.
The public class implements TableThread Runnable {Private WebDriver driver; Private string thread; Tabletrate (WebDriver Driver, String Thread) {this.driver = driver; This.thread = Thread; } @ Override Public Wide Run () {getTableRow (); } Private string getTableRow () {System.out.println ("start getting elements" + thread); Web element table element = driver.finded element (bay classname ("logo")); String href = tableElement.getAttribute ("href"); System.out.println ("table at:" + thread + "" + href); Return href; }} and the caller for that method
for (int i = 0; i <10; i ++) { Executioner Service Thread Expector = Exporter newSingleThreadExecutor (); Tabletread tabletread = new tableread (driver, "thread" + i); ThreadExecutor.execute (tableThread); Thread.Sleep (50); } Errors while setting this download = ThreadGuard.protect (driver);
Getting Elements Initially "Pool-1-Thread-1" Org.openqa.selenium.WebDriverException: Thread Security Error; This example of the WebDrive was made on the thread main (ID1) and it is being used by Thread Pool-1 Thread-1 (ID-26), and is not allowed * due to unchanged behavior * < / Pre> errors with setting this.driver = driver; Exceptions in thread "pool-2-thread-1" org.openqa.selenium.UnsupportedCommandException: Error 404: Exception in thread "Pool-1-thread-1" java.lang .classCastException: org.openqa.selenium.remote.RemoteWebElement can not be entered on java.lang.String
thanks in advance!
Just add the comment of ADDCJar that the Web Player class is not secure; I have found the following problem which I believe is related to this question:
If this is the same issue that you have, then a solution is to synchronize your call to the WebDriver. Synchronized Interant Explorer Driver. Java has been solved by creating a class, which synchronizes the call for the underlying WebDriver.
Let me tell you that it is able to exclude thread issues as a reason (using this synchronized interactive explorer driver).)
< Strong> code snippet:
public class synchronized InternetExplorerDriver InternetExplorerDriver override extended {... @ secure response execution (string driver comand, map & lt; string, & gt; parameter ) {Synchronize (getLock ()) {return super. Execute (Driver Commands, Parameters); }} @ Override Secure Response Execution (String Command) {synchronize (getLock ()) {return super.execute (command); }} ...} Full code:
No comments:
Post a Comment