Похожие чаты

Good afternoon, colleagues🖐 I have the following question. I'm debugging my

own project. I have two separated classes, which use two separated threads in Main class.

While going through debug of the class, which running one of 2 websites, I open the website another one.

So, my situation is the next. Here's one of 2 classes:

public class GBFeedReader implements Runnable {

//private static ChromeOptions chOptions;
private DatabaseConnections databaseConnections = new DatabaseConnections();

public void run() {

// Setup ChromeDriver using WebDriverManager
WebDriverManager.chromedriver().setup();

// Set Chrome options and capabilities
ChromeOptions chromeOptions = new ChromeOptions();
//WebDriverManager.chromedriver().browserVersion("119.0.6045.160").setup();
//WebDriverManager.chromedriver().capabilities(chOptions).setup();
//WebDriverManager.chromedriver().capabilities(chromeOptions).setup();

chromeOptions.addArguments("--headless");
chromeOptions.addArguments("--disable-gpu");
chromeOptions.addArguments("--disable-extensions");

ChromeDriver driver = new ChromeDriver(chromeOptions);
driver.get("https://....");
...

and the 2-nd one as below:

public class BGFeedReader implements Runnable {
private DatabaseConnections databaseConnections = new DatabaseConnections();

public void run() {
ChromeOptions options = new ChromeOptions();
//WebDriverManager.chromedriver().browserVersion("118.0.5993.118").setup();
//WebDriverManager.chromedriver().browserVersion("114.0.5735.90").setup();
//WebDriverManager.chromedriver().setup();
/*options.addArguments("--headless");
options.addArguments("--disable-gpu");
options.addArguments("--disable-extensions");*/

ChromeDriver driver = new ChromeDriver(options);
driver.get("https://www.banggood.com/new-arrivals.html");
//driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(30));

...

I'm binding them as below:

public static void main(String[] args) {
//PropertyConfigurator.configure("D:\\IdeaProject\\maven-bot\\src\\main\\resources\\log4j.properties");
// creation pool with 2 threads
//A ScheduledExecutorService is capable of scheduling
// tasks to run either periodically or once after a certain amount of time has elapsed.
ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(2);

long initialDelay = 0; // the time from now to delay execution - первоначальная задержка
long period = 1; // the period between successive executions - повторение ежедневное
scheduler.scheduleAtFixedRate(new GBFeedReader(), initialDelay, period, TimeUnit.DAYS);
sleepThread();
scheduler.scheduleAtFixedRate(new BGFeedReader(), initialDelay, period, TimeUnit.DAYS);
ApiContextInitializer.init();

// ...
}

As result, the code is running instead of the class GBFeedReader, the class BGFeedReader

The question, am I missing something here? My configuration of the running debug the next one (screen)

Thanks in advance for any ideas, if you're included in my topic, because I'm still confusing with it. Maybe, I'm missing multithreading some detailes under the hood.

5 ответов

47 просмотров
Nan0- Автор вопроса
Nan0- Автор вопроса

If I find the way how to fix it, I'll update the question here👍

Nan0- Автор вопроса

Under the phrase as: "As result, the code is running instead of the class GBFeedReader, the class BGFeedReader" I mean it opens me the website of the another class absolutely, for some reason.

Nan0- Автор вопроса
Nan0
Under the phrase as: "As result, the code is runn...

In short, from the last updates. I have a different result on the different versions of Selenium. For example, if you take versions from 3.x.x, then the wrong site opens when using several threads, but if you take from 4.x.x, it generally ignores and does not open anything, no browsers. My first conclusion is that this is related to versioning, but how to get around it, this is tough a question, as for now.

Nan0- Автор вопроса
Nan0
In short, from the last updates. I have a differen...

The cause was in these lines: chromeOptions.addArguments("--headless"); chromeOptions.addArguments("--disable-gpu"); chromeOptions.addArguments("--disable-extensions"); I simply forgot I didn't comment these lines in Gearbest class, but I commented it in BGFeedReader

Похожие вопросы

Обсуждают сегодня

30500 за редактор? )
Владимир
47
any reference of this implementation?
BitBuddha
29
Ⓐrtto, [4/23/24 7:02 PM] Please explain more fully how it is not working exactly, and what are the steps you are taking, and what error messages come or what happens. Ⓐrtto, ...
Ezza Kezza
2
sounds like people have lost their kaspa on tradeogre... does this mean tradeogre not trustworthy?
Ezza Kezza
15
Страшнейшая правда про списки ЦБ. С первых дней жизни P2P сферы, молодые человеки, начитавшись законодательной базы и "внутренних" документов, решили, что им противостоит сер...
Foxcool
3
Недавно Google Project Zero нашёл багу в SQLite с помощью LLM, о чём достаточно было шумно в определённых интернетах, которые сопровождались рассказами, что скоро всех "ибешни...
Alex Sherbakov
5
So much speculation in the last week. So much volatility in price. This is because Hedera has a GC that isn't using the network it's governing. Why aren't people asking why a...
Summit Seeker R
8
Anyone else having this error when trying to make transactions?
Datzel
11
Question: How viable is it to use Anvil as the backend infrastructure for managing a TradFi portfolio, while integrating Flexa for instant liquidity and payment solutions? Cou...
Kevin
2
вы делали что-то подобное и как? может есть либы готовые? увидел картинку нокода, где всё линиями соединено и стало интересно попробовать то же в ddl на lua сделать. решил с ч...
Victor
8
Карта сайта