Search
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
» how to connect DB in selenium webriver
Fri Oct 06, 2017 4:09 pm by anbarasi

» How find any text in browser screen and click on it?
Thu Oct 05, 2017 2:02 pm by sandeepkommineni

» Selenium Webdriver
Tue Oct 03, 2017 1:35 pm by PiyushBiswas

» GRID setup tutorial.
Wed Sep 27, 2017 4:29 pm by johnyapp

» Drag & Drop Between Windows Using Selenium Driver
Wed Sep 27, 2017 2:10 pm by 26rondel

» Check if window is closed / verify input
Sat Sep 23, 2017 10:21 pm by brainstir

» How to work on pages with AJAX in selenium?
Mon Sep 18, 2017 6:08 pm by azharuddin

» pause test until user press a key like F2
Wed Aug 09, 2017 11:10 pm by djnforce

» Selecting the input for auto populating element
Sat Jul 29, 2017 7:53 pm by kdabbara

Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

webdriver + python, how to check for presence of text on page?

View previous topic View next topic Go down

webdriver + python, how to check for presence of text on page?

Post by eTo on Mon Jul 30, 2012 4:26 am

Hi.
I'm looking for way to check if certain text visible on page while. Is that possible somehow?
All i could find so far, is to check if certein element if present. But let's assume that there is no clear identification of this element, and text it self is not link, Just need to check if i'ts displayed somewhere on page or not, but can't seem to find any simple way like verify from ide plugin.
And another question, how to identify element that contains searched text?

eTo

Posts : 2
Join date : 2012-07-30

Back to top Go down

Re: webdriver + python, how to check for presence of text on page?

Post by Sagot on Mon Jul 30, 2012 6:10 pm

1. How do I know whether text is present on the page or not (yes/no) without getting a webelement:

String allPageCode = driver.getPageSource(); - we get a big String with all html code.
allPageCode.contains("some text to look for"); - return true / false is it present on the page or not.

this code is for Java but definitely there are the same functions in python!


2. How to get a webelement if we know just text that it must contain? And how to get to know if this text is VISIBLE (not just existing in page source code)?

We use xpath! How to locate:
Element containing text 't' exactly - //*[.='t']
Element containing text 't' - //E[contains(text(),'t')]

When we get the element by xpath we can verify it's visibility on the page:
element.isDisplayed(); - returns true or false;

this is Java code but there are same functions and methods for python as well.



P.S. I strongly recommend to use this helper tables for XPath https://docs.google.com/open?id=0B5Y65du7slVnZkVfaHJrSWtvd2c or https://docs.google.com/open?id=0B5Y65du7slVnWlB0b3BhNThzczA

Sagot

Posts : 4
Join date : 2012-07-05

Back to top Go down

Re: webdriver + python, how to check for presence of text on page?

Post by eTo on Wed Aug 01, 2012 5:22 am

Actually i think there are no such functions in python webdriver... searched module it self for them and didn't find them :/
Thought there might be some workaround for that but i guess except launching java or code from other programming language there is no option to stay 100% in python. And since i'm newbie in python... then i guess i stick to rc server.
Thx for those tables though, they have already proven them self useful Smile

eTo

Posts : 2
Join date : 2012-07-30

Back to top Go down

Re: webdriver + python, how to check for presence of text on page?

Post by TankorSmash on Tue Sep 11, 2012 11:12 am

Hey dude, I found this page through google, and then later solved my problem. The solution is page_source attribute

Code:
from selenium import webdriver
br = webdriver.Ie()
br.get('google.com')
print br.page_source

TankorSmash

Posts : 1
Join date : 2012-09-11

Back to top Go down

Re: webdriver + python, how to check for presence of text on page?

Post by Sponsored content


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