Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

231
Views
How can I select text in an element that isn't inside another element?

I have a problem with some css selector (I have only one way to find an element if I use JS commands so only CSS selector is available for me) The page looks like this:

<div class='test'>
some_text
<span> some_other_text </span>
</div>

And I need to get some_text without getting "some_other_text"; I tried to use: By.CssSelector("div[class='test'] :not(span)") >> it returns all text; By.CssSelector("div[class='test'] span:not(last-child)") >> it returns only "some_other_text"; By.CssSelector("div[class='test'] span:not(:last-child)") >> it returns only "some_other_text"; By.CssSelector("div[class='test']:not(:last-child)") >> it returns only "some_other_text";

is there any way to do what I need? could anyone help me , please?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!