nateshmbhat / webbot

Web automation library for simple and easy end to end testing and web browser automation that offers super charged features while keeping it simple to use and master
https://pypi.org/project/webbot/
Mozilla Public License 2.0
239 stars 87 forks source link

[Suggestion] Get text content from element #35

Closed NobleFalcon closed 3 years ago

NobleFalcon commented 4 years ago

Hi there, in my current program I need an option to fetch data from elements on the page while the bot is working as the value is from a timer that is constantly changing, is it possible that you could add that?

Kind regard's BlackFalcons

NobleFalcon commented 4 years ago

I solved this by accessing the driver element of webbot which have access to the selenium packages that I needed.

So Browser().driver gave me access to plain selenium modules which allowed me to use the selenium_element.text

AronHegedues commented 3 years ago

Hi, I'm also interested how to convert a found element into text, but I couldn't really figure it out following your instructions.

So Browser().driver gave me access to plain selenium modules which allowed me to use the selenium_element.text

Could you please share a code example how you've done it?

NobleFalcon commented 3 years ago

Hi, I'm also interested how to convert a found element into text, but I couldn't really figure it out following your instructions.

So Browser().driver gave me access to plain selenium modules which allowed me to use the selenium_element.text

Could you please share a code example how you've done it?

Hi @Simplicitus,

There is no documentation about this, I found the solution in the source code. So first I imported the Browser module from webbot from webbot import Browser. The browser module has access to the selenium web driver module which this API is relying on. Then you can get elements with selenium however you like just follow the Selenium documentation on how to select elements, when the element you want text from is selected you can use the .text attribute on that element to get the text.

AronHegedues commented 3 years ago

Thanks for your answer @BlackFalcons,

so do I understand correctly that there is no way to transfrom web.find_elements() to text, but I have to use the Selenium native web.driver.find_element().text instead?

NobleFalcon commented 3 years ago

Yeah @Simplicitus.

As far as I know that is correct, I spent a few hours researching before diving into the source code of the webbot library where I in the end found out how to use plain selenium to this spesific task. I find it inconvenient that a task this simple is not easier to access through the webbot API. I was planning to make a pull request and implement it but I never took the time back then.