L
L
lorrrtemar2021-04-02 16:27:51
Java
lorrrtemar, 2021-04-02 16:27:51

What is the problem here (Selenium WebDriver + JAVA)?

I started developing tests on JAVA + Senelium WebDriver. I want to understand the simplest things, transitions, clicks, selections, etc. There was a problem. I made the transition to the Yandex market using By.linkText, but the market landmark does not want to work for me either on the selector or on the xpath. Approximately, such error in the given code is highlighted. What could be the problem? I'm attaching screenshots of the code and errors. I understand that it does not find the element when it is visible in the Google inspector.
60671bb947ca1166051119.png
60671b8e7f002592939713.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Araya, 2021-04-02
@Araya

For a large number of sites, classes are randomly generated, like in your screenshot. They have a property - to change over time, write a locator without generated classes.
And download a normal IDE

O
Orkhan, 2021-04-02
Hasanly @azerphoenix

Good afternoon!
First, when writing a question, post the error code and the code itself, wrapping it with the appropriate tag. Screenshots are not the best idea, because they impair readability + it is difficult to comment on this or that code, and copying your code from a screenshot is a so-so idea.
As for your problem, you are faced with a site that generates content dynamically (i.e. it is some kind of js framework - angular, svelte, vue, react etc.). When generating content dynamically, some class selectors are also dynamically generated. Accordingly, selecting an element by CSS class will not work. or it won't always work. And since not every element has an ID, you won't be able to use it either.
What can be done?
- Use XPATH, but don't bind to a class.
Although, from my own experience, I’ll say that once I came across a site that, moreover, changed the structure of the virtual DOM with each page update and, accordingly, XPATH sampling did not work either.
On the other hand, if you are using Selenium to develop a certain parser, then it is better to study the Yandex Market API and work with it.
https://yandex.ru/dev/market/content-data/
https://yandex.ru/dev/market/index/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question