¿Cómo puedo obtener y almacenar el ID de usuario de la URL en una prueba de Selenium?

I'm recording Selenium tests using Selenium IDE to test the registration flow of my drupal site, which depends heavily on the rules module.

Some of the tests involve the registration of user accounts. Since I will be using these tests on multiple servers with different amounts of users, I do not know upon starting the test which user ID to check for. Since the user ID is in the URL, I was hoping to grab it and store it in Selenium.

Upon logging in, users are redirected to a URL like http://192.168.100.100:8888/en/user/6, where "6" is the UID.

I imagine that I could use Selenium's storeValue command to do this, but what should I put as the target to pull the user ID out of the URL?

preguntado el 09 de marzo de 12 a las 14:03

2 Respuestas

store | http://192.168.100.100:8888/en/user/6  | string
store | 1  | delimiter
store | javascript{storedVars['string'].split('user/')[storedVars['delimiter']]} | result
echo  | ${result}

Or

storeLocation | string
store | 1  | delimiter
store | javascript{storedVars['string'].split('user/')[storedVars['delimiter']]} | result
echo  | ${result}

Result will be 6

respondido 10 mar '12, 05:03

Thank you! To get the URL, I used storeLocation instead of store. Otherwise, I was able to get it working just as you wrote. - Patricio Kenny

You could do this by grabbing the url and parsing the string for the user ID if you are using RC or Selenium 2.

For specific help you'll have to shed some light on what version of Selenium you are using (IDE, Selenium RC, Selenium 2/Webdriver) and what language?

If you have a sample URL string you can get a more exact answer as well.

respondido 10 mar '12, 00:03

Thanks. The question got moved so I've updated it appropriately. I'm new to Selenium testing so I'm using the IDE to record tests. - Patricio Kenny

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.