Search code examples
pythonseleniumstock

how can i set input text and then click on first item in dropdown list


hi how can I type 'غاذر' in search

and then click on first item in dropdown list

i simulate it by gif

enter image description here

you can find html file here

https://github.com/saeedzali94/tehranindex/blob/main/%DA%A9%D8%A7%D8%B1%DA%AF%D8%B2%D8%A7%D8%B1%DB%8C%20%D9%85%D9%81%DB%8C%D8%AF%20(1).html

the elements of search box is

<input id="txt_search" class="search-box tp-co-1 tp-pa-rl-5 tp-re tp-bo-bo" type="text" placeholder="جستجوی سهم" onmouseup="this.select();" autocomplete="off" style="display: block;">

the elements of dropdown list is

<div id="list_dropdown"><div isin="IRO1PIAZ0001" symbol="غاذر1 - کشت‌وصنعت‌پیاذر"><span></span><span style="color: red;">غاذر</span><span>1 - کشت‌وصنعت‌پیاذر</span></div></div>

Solution

  • These are base classes. Base classes are similar to interfaces in the way they declare some abstract methods that will be implemented by their subclases but base classes have some methods implemented that will be inherited. Base classes should not be instanciated, that is why they raise NotImplemented errors in their abstract methods so you are forced to not instance them. If you look at ParamOperation class, it inherits from Operation and it should but it is not implementing its abstract methods. That's what the comments are telling you. A more pythonic way to create Base classes is inheriting your Base class from ABCmeta and using @abstractmethod like in this repo: https://gitlab.com/TuringFactory/tf_page/tf_backend/-/tree/dev/main/shared

    The repo you shared is a little confusing since it is not implementing abstract methods in the subclasses. I do not recommended it for learning this topic.