Giter Club home page Giter Club logo

Comments (7)

alp82 avatar alp82 commented on August 26, 2024

This is clearly a bug. I will look into this as soon as possible.

from abmash.

nobal avatar nobal commented on August 26, 2024

Thanks. I noticed that in my code above, if you put only text() predicate or only closeTo(me) predicate, you still get the same result i.e. the find() method returns HtmlElements of size 1. This observation might be helpful to figure out the bug...

from abmash.

alp82 avatar alp82 commented on August 26, 2024

I have a question concerning the expected result. You are right that the text "Name" does not appear in the result set, which should happen in some way. But, the whole text is contained in one element without seperation:

<span style="font-size:large">
    Name
    <span style="font-size:small""> type your name</span>
</span>

If you get the text for the inner span you will get "type your name". The outer span returns "Name type your name" (or at least it should after resolving this bug).

But i guess the result you wanted would be something like this:

1 Name
2 type your name

If that's the case, the HTML markup needs to be changed a little bit, so that the text "Name" is surrounded by its own tag:

<span style="font-size:large">
    <span>Name</span>
    <span style="font-size:small""> type your name</span>
</span>

Are my assumptions right and what do you think about it?

from abmash.

nobal avatar nobal commented on August 26, 2024

Based on the documentation, I expect two items in the result list as you guessed. Normally, I don't have right to change the HTML code of the page I'm working on.

I was wondering whether you fixed this bug. If yes, please let me know the new version id.

from abmash.

alp82 avatar alp82 commented on August 26, 2024

You are right that changing the source code is mostly not an option. I fixed the bug, but i am not sure if you agree with the solution. Therefore i will wait with the new version number until you are ok with it.

Here is the current output of your code:

Total texts around me: 2
1  type your name
2 
            Name
             type your name

We have a semantical problem here. Let's assume we have html markup that is structured like this:

<div>
    There are <strong>3</strong> new messages
</div>

Now, there are technically two elements. The <div> and the <strong>. An alternative would be to automatically add "virtual" tags around the unmarked text bits like so:

<div>
    <span>There are</span> <strong>3</strong> <span>new messages</span>
</div>

Which would result in 4 elements: <div>, <span>, <strong> and a second <span>. I am not sure if that's the expected behavior in most cases.

The same applies to your html:

<span style="font-size:large">
    Name
    <span style="font-size:small""> type your name</span>
</span>

This returns the two <span> elements, but the text "Name" does not stand for itself. The first span contains the whole text "Name type your name" and the second the text of the inner span "type your name". It's difficult to tell if people would expect a separation of the text without markup ("Name") and the inner span ("type your name") when comparing the result to their visual perception of the page.

As you can see, i have a hard time on deciding which is the right way to go. But maybe you can tell me more about the task you want to achieve so that we can elaborate more on this problem.

from abmash.

nobal avatar nobal commented on August 26, 2024

Yes, this is tricky. I don't think adding extra tags would be a good idea. I wanted to get the visible label of the field I am interested in. That is, I want "Name type your name" as my label for the input tag in my html. So, using the current output of my code that you provided with the new changes, I can easily get that.

from abmash.

alp82 avatar alp82 commented on August 26, 2024

I incremented the version to 0.2.6-SNAPSHOT. Feel free to test it and give feedback.

from abmash.

Related Issues (5)

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.