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)

From "Jukka K. Korpela" <jkorpela@cs.tut.fi>
Newsgroups comp.lang.javascript
Subject Re: how to get the element by text (innerHTML)
Date 2012-10-29 11:23 +0200
Organization A noiseless patient Spider
Message-ID <k6lhv6$ctr$1@dont-email.me> (permalink)
References <fdd894aa-524c-475c-b0be-9ee93c7f461a@googlegroups.com>

Show all headers | 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