S
S
sidorikv2020-09-24 04:49:46
HTML
sidorikv, 2020-09-24 04:49:46

How can you find an element on the page if its id is constantly changing?

You need to find the element on the page in any way. I tried to find it via id, Xpath, TagName, but alas. The whole problem is that the id of the element ( input - which I'm looking for) is constantly changing, changing after a reload. I'm trying to find it through selenium c#.
Can anyone please tell me how to get around this moment with the change of id and how to find this very element in the end?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
DevMan, 2020-09-24
@sidorikv

elementary: do not get tied to the id.
any element on the page will always have some parameter that is unique to it: a specific attribute / position relative to the parent(s) / and all that.
all this is elementarily solved by ikspas, if you know how to do it.

S
Sergey Zenkovich, 2020-09-24
@JamesHatfield

1) You can add an attribute to an element and search by attribute.
2) If the parent has only one element, then you can refer to it through the parent, for example:
document.querySelector('.el:first-child'); or
document.querySelector('.el:nth-of-type(1)');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question