Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #16944

Re: how to get the element by text (innerHTML)

Path csiph.com!usenet.pasdenom.info!gegeweb.org!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail
From "Jukka K. Korpela" <jkorpela@cs.tut.fi>
Newsgroups comp.lang.javascript
Subject Re: how to get the element by text (innerHTML)
Date Mon, 29 Oct 2012 11:23:49 +0200
Organization A noiseless patient Spider
Lines 25
Message-ID <k6lhv6$ctr$1@dont-email.me> (permalink)
References <fdd894aa-524c-475c-b0be-9ee93c7f461a@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
Injection-Date Mon, 29 Oct 2012 09:23:50 +0000 (UTC)
Injection-Info mx04.eternal-september.org; posting-host="9e0ae8574c58208bf47738e1c9986fe4"; logging-data="13243"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/9GXstE96xTSVGetPKKYnc"
User-Agent Mozilla/5.0 (Windows NT 6.1; rv:16.0) Gecko/20121010 Thunderbird/16.0.1
In-Reply-To <fdd894aa-524c-475c-b0be-9ee93c7f461a@googlegroups.com>
X-Antivirus-Status Clean
X-Antivirus avast! (VPS 121028-1, 28.10.2012), Outbound message
Cancel-Lock sha1:5fwG95w2gQ2yRn4HQkHKYtLmUf8=
Xref csiph.com comp.lang.javascript:16944

Show key headers only | View raw


2012-10-29 10:52, gaurangnshah@gmail.com wrote:

> I am working as automation engineer. and I have a weird requirement where i need to click on the element by it's innerHTML.
>
> Now this innnerHTML may present multiple times in the page but only one would be visible at a time others would be hidden. I have to click on the visible text.
>
> Any idea how can i achieve this ?

I'm afraid I can't see what the question means. When something is 
visible on a page, it's the content of the innerHTML property that is 
displayed, formatted by HTML and CSS rules, you can click on it. What 
could it possibly mean to click on "innerHTML" in another sense?

If you mean *searching* an element by its innerHTML, then you would need 
to set up a JavaScript function that traverses the document tree and 
compares the search string with innerHTML properties, or use a library 
that does such things. But finding out which of several matches is 
*visible* is a tricky issue, since there are many ways to make elements 
invisible. If only one technique is used for this (say, style.display 
set to 'none'), then things get much easier.

Please show some example of what would really be going on.

-- 
Yucca, http://www.cs.tut.fi/~jkorpela/

Back to comp.lang.javascript | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

how to get the element by text (innerHTML) gaurangnshah@gmail.com - 2012-10-29 01:52 -0700
  Re: how to get the element by text (innerHTML) "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2012-10-29 11:23 +0200

csiph-web