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

Grabbing the current URL and storing it as a string.

View previous topic View next topic Go down

Grabbing the current URL and storing it as a string.

Post by ramsen on Wed Jan 19, 2011 5:55 am

I'd like to store the URL of the page I'm on as a string. I tried using window.location.href to grab the URL from the current window, but since the current open window is Selenium IDE and not the web page it does not work. Is there another way I can take the URL and store it using javascript or Selenium commands?

I want to be able to check the URL and change certain variables based on the URL.

ramsen

Posts : 5
Join date : 2011-01-19

Back to top Go down

Re: Grabbing the current URL and storing it as a string.

Post by ramsen on Wed Jan 19, 2011 8:18 am

I actually figured out how to grab the URL, but I'm still stumped on how to parse the string.

I used the command:
storeLocation | site | |

Now I would like to get the data in "site" and parse it as a string.

ramsen

Posts : 5
Join date : 2011-01-19

Back to top Go down

Re: Grabbing the current URL and storing it as a string.

Post by Priyanka on Wed Jan 19, 2011 7:09 pm

Pls try this


string site = selenium.GetLocation();
string[] location = site.Split('/');

for(int i = 0; i < location.length; i++)
{
Console.WriteLine(location[i]);
}

Priyanka
Regular Participant
Regular Participant

Posts : 27
Join date : 2010-10-04

Back to top Go down

Re: Grabbing the current URL and storing it as a string.

Post by ramsen on Thu Jan 20, 2011 5:47 am

I'm actually close to getting this to work, but now I hit an exception every time.
[error] Threw an exception: missing ; before statement


I have only two commands.
1. storeLocation | site | |

2. storeEval | js code below | n |

Code:

javascript{
    var n = ["Is Google" , "Not Google"];
    if(storedVars['site'] == "http://www.google.com/")
    {
        n[0];
    }
    else
    {
        n[1];
    }
}

If I change my array to contain integers instead of strings the code works. Why would using strings cause an error?
For example; if I change var n = ["Is Google" , "Not Google"]; to var n = [100 , 200]; the code works perfectly.

Thanks for the help.

ramsen

Posts : 5
Join date : 2011-01-19

Back to top Go down

Re: Grabbing the current URL and storing it as a string.

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