Coder Social home page Coder Social logo

Comments (6)

stevepryde avatar stevepryde commented on July 28, 2024 1

Waiting for the page to finish loading can be complicated. There is no magic solution because there is no clear definition of when a page has "finished loading".

I highly recommend thinking in terms of what a human would do, and emulating that. If it's difficult to emulate it, then it's a strong indication that your page UX is a little unclear even for a human.

In this case, consider waiting for the button to be displayed with the relevant text. Use the driver.query(..) method for this.
https://docs.rs/thirtyfour/latest/thirtyfour/extensions/query/struct.ElementQuery.html.

This will poll for an element with the given selector. You can use xpath to match the button text within the selector.

This crate is just a selenium/webdriver client so it can do anything selenium/webdriver can do. For general selenium or webdriver questions like this I'd recommend searching the selenium documentation or other webdriver related forums for answers.

from thirtyfour.

Daniel-Xu avatar Daniel-Xu commented on July 28, 2024

Second question:

for a simple html snippet:
2023-12-02 at 21 10

after getting the error element:

let elem_error = driver.find(By::Id("errorContainer")).await?;

I can't get the textContent by using elem_error.text().await?
the child elements are not included in the search result?

from thirtyfour.

Daniel-Xu avatar Daniel-Xu commented on July 28, 2024

is there a Css select reference?
"#errorContainer div" this css selector doesn't work, the error message is:
run should be ok: no such element: CSS(#errorContainer div)

from thirtyfour.

stevepryde avatar stevepryde commented on July 28, 2024

If you want the html rather than the visible text, you should use the inner_html() method
https://docs.rs/thirtyfour/latest/thirtyfour/struct.WebElement.html#method.inner_html

from thirtyfour.

stevepryde avatar stevepryde commented on July 28, 2024

Regarding your login button question, once you have selected an element, any operations on that element will always refer to that specific element. It won't do the "find" again. However, when you initially get the element via "find()", make sure you're getting the right one. It will always give you the first one it finds, searching from the top of the html.

Have a look at xpath selectors for more control over it

from thirtyfour.

Daniel-Xu avatar Daniel-Xu commented on July 28, 2024

Regarding your login button question, once you have selected an element, any operations on that element will always refer to that specific element. It won't do the "find" again. However, when you initially get the element via "find()", make sure you're getting the right one. It will always give you the first one it finds, searching from the top of the html.

Have a look at xpath selectors for more control over it

if I need to find the element again, how can I make sure that the page is finishing reloading? (from signup -> login)

from thirtyfour.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.