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

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 Today at 3:49 pm


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