Search
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
» FlexMonkium Download Not available under Gorillalogic site
Thu Dec 08, 2016 5:40 pm by bhanu.praveen

» Selenium Script issue
Tue Dec 06, 2016 9:48 pm by njain213

» Difference between QTP, Selenium and Silk test
Tue Dec 06, 2016 7:58 pm by jessicacyrus1

» Where does selenium script pick browser from
Tue Dec 06, 2016 1:52 pm by janbaskt

» Safari throws an HTTP ERROR: 404
Tue Dec 06, 2016 1:51 pm by janbaskt

» Access Denied Error in Selenium RC
Tue Dec 06, 2016 1:51 pm by janbaskt

» Automating Flex application through selenium webdriver
Fri Dec 02, 2016 2:06 pm by abhinay.krs

» Starting with Selenium, what is Selenium?
Mon Nov 28, 2016 4:00 pm by Foma

» Getting started with Selenium
Mon Nov 28, 2016 3:23 pm by Rebbelx

Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

Dynamic webelement verification

View previous topic View next topic Go down

Dynamic webelement verification

Post by rohit kumar gupta on Mon Nov 05, 2012 11:54 am

Hi popsha:-
The line in bold below is what i want to validate.
<div id="main-content">

<div class="module-advert" style="overflow:visible">


<span class="corners-top">

<div class="inner">

<span class="corners-bottom">
</div>

<div style="height:3px"></div>

<p class="right rightside">Your last visit was on Sun Nov 04, 2012 10:11 am</p>

<p>Current date/time is Sun Nov 04, 2012 11:34 pm</p>

<br class="clear">

<ul class="linklist">

<div class="forabg">

<div class="forabg">

<div class="forabg">
<ul class="linklist">

rohit kumar gupta
Active particpant
Active particpant

Posts : 24
Join date : 2012-09-19
Age : 26
Location : abc

Back to top Go down

Re: Dynamic webelement verification

Post by popsha on Mon Nov 05, 2012 1:30 pm

Dear Rohit,

As I understand from your code, only the "text" changes and not the web element. It means,

....

is static.

If I'm right, both xpath-relative and xpath-absolute should work in your scenario. Please let me know the errors it throws.

Because I tried this in my tool with similar scenarios.

popsha
Amateur
Amateur

Posts : 60
Join date : 2012-04-14

Back to top Go down

Re: Dynamic webelement verification

Post by rohit kumar gupta on Tue Nov 06, 2012 11:34 am

Hi Popsha,

I am trying this:-

System.out.println(driver.findElement(By.xpath("//div[@id='main-content']/p[2]")).getAttribute("Text"));

but it fetches null.

I tried this with other attributes like name,value but no result.

I was actually thinking if we can pass text as parameter and identify the webelement.

rohit kumar gupta
Active particpant
Active particpant

Posts : 24
Join date : 2012-09-19
Age : 26
Location : abc

Back to top Go down

Re: Dynamic webelement verification

Post by tarun3kumar on Tue Nov 06, 2012 2:26 pm

rohit kumar gupta wrote:Hi Popsha,
System.out.println(driver.findElement(By.xpath("//div[@id='main-content']/p[2]")).getAttribute("Text"));

but it fetches null.

It fetches null because there is no such attribute called - "Text". You need to use getText() method -

Code:
System.out.println(driver.findElement(By.xpath("//div[@id='main-content']/p[2]")).getText());
I assume that your xPath is correct!

_________________
Thanks
Tarun K
Free Selenium Training

tarun3kumar
Master
Master

Posts : 186
Join date : 2012-02-14

http://seleniumtests.com

Back to top Go down

Re: Dynamic webelement verification

Post by popsha on Wed Nov 07, 2012 10:34 am

Yes, tarun is correct.

popsha
Amateur
Amateur

Posts : 60
Join date : 2012-04-14

Back to top Go down

Re: Dynamic webelement verification

Post by rohit kumar gupta on Wed Nov 07, 2012 11:43 am

Thanks Tarun and Popsha....

Just another doubt. In doing gettext() i will have to write an if statment to compare texts. Is there a way where in i can pass the text and check for presence of the webelement. Something similar to checkpoint of qtp...

rohit kumar gupta
Active particpant
Active particpant

Posts : 24
Join date : 2012-09-19
Age : 26
Location : abc

Back to top Go down

Re: Dynamic webelement verification

Post by popsha on Wed Nov 07, 2012 2:35 pm

can achieve this in different ways by hard coding it.

try using .equals method

popsha
Amateur
Amateur

Posts : 60
Join date : 2012-04-14

Back to top Go down

Re: Dynamic webelement verification

Post by Sponsored content Today at 3:24 am


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum