Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question #4

Open
cvega opened this issue May 12, 2016 · 3 comments
Open

Question #4

cvega opened this issue May 12, 2016 · 3 comments

Comments

@cvega
Copy link

cvega commented May 12, 2016

I see your example of using text. If I assign text to the page object in your example, everything works fine. If I don't I just get None type. I want to extrapolate the text from the page object. Maybe I'm doing it wrong?

@bikemule
Copy link

bikemule commented Aug 4, 2016

I'm not an expert on this and I'm not sure which part of the tutorial you're referring to, but I hate to see unanswered questions.

You can always access the driver directly: https://page-objects.readthedocs.io/en/latest/tutorial.html#accessing-the-webdriver-directly Something like this: some_page_object.w.find_element_by_id("the_form").text

@eeaston
Copy link
Collaborator

eeaston commented Sep 8, 2016

Hi there,
Sorry for the very slow reply and thanks @bikemule for helping out!
@bikemule is correct you can always access the driver directly in the manner he described.
To do this natively you'd define a page element on the page object, and access it's 'text' property.

For example the following html:

<html>
<head></head>
<body>
    <div id="my-text-box">Lorum Ipsum</div>
</body>
</html>

Here's the python to access the text of the div box:

from page_objects import PageObject, PageElement
from selenium import webdriver
class MyPage(PageObject):
    textbox = PageElement(id_='my-text-box')

driver = webdriver.PhantomJS()
p = MyPage(driver)
the_text = p.textbox.text
assert the_text == 'Lorum Ipsum'

If this doesn't work, the page element constructor might be incorrect and you're picking up the wrong element.

@klubi
Copy link

klubi commented Oct 12, 2016

Hi

I'll use this issue instead of creating new one.
How can I check if particular PageElement is displayed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants