Website generates dynamic ID for Selenium IDE

Working with Selenium IDE 2.9.1, a plugin for Firefox, I am trying to store the dynamically created ID of a new document and open it at the end. For example:

  • I create a document, and the DataBase automatically assigns the ID: dp_137282
  • Following this, there is Selenium code that performs other tasks.

  • However, at the end, Selenium should locate my document by its ID and open it using a double click command.

Please review the code below:

<div id="content" style="height: 373px; width: 1324px;">
<div class="main-content" rel="kancelaria/rkp/rkp-faktury/type//rok_roboczy/2017">
<h3 class="gray">
<form class="form" action="kancelaria/rkp/rkp-faktury/type//rok_roboczy/2017" onsubmit="">
<input style="display:none;" value="asd" type="submit">
<div id="flex-list">
<table id="kancelaria-rkp-index" class="dark-gray overlap" style="width:100%;" headlines="">
<thead>
<tr id="dp_137282" class="multi-selectable" style="" ondblclick="this.className += ' doubleclicked'; Load.Content('kancelaria/rkp/szczegoly-rkp-faktury/id/dp_137282')" data-b="kancelaria/rkp/szczegoly-rkp-faktury/id/dp_137282" onclick="" data-status="">

Click here to view an image related to this topic

At the end, I used xpath in the Target field:

xpath=(//td[@onclick=' '])[7]

I have noticed that newly created documents by Selenium always appear at the top, so opening them shouldn't be an issue, but I prefer not to rely on this behavior. If anyone knows a solution and can share it, I would greatly appreciate it.

Answer №1

If you need to save the ID attribute from a <td> tag, you can make use of the storeAttribute command.

For example:

<tr>
    <td>storeAttribute</td>
    <td>xpath=//table[@id='kancelaria-rkp-index']/thead/tr/@id</td>
    <td>dynamicvalue</td>
</tr>

This code snippet will capture and store the dynamic ID value.

Once you have stored the ID, you can then retrieve and use it like this:

<tr>
    <td>echo</td>
    <td>${dynamicvalue}</td>
    <td></td>
</tr>

To display the value of the ID attribute

<tr>
    <td>clickAndWait</td>
    <td>id=${dynamicvalue}</td>
    <td></td>
</tr>

To click on an element with the stored ID attribute

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the best method to make an email address distinct?

<body> <p>Please input your email address:</p> <input id="email" style="margin-bottom: 20px; margin-top: 2px;" type="email" placeholder="Email Address"> <input onclick= "validateEmail(email)" type="su ...

Using Selenium in Java, you can click on an element if it exists, and if it is not found, simply move on

I am currently in the process of developing a script to test a JavaScript application on a website. While most of the code is complete, I have run into an issue. The purpose of the script is to modify a question on the website that utilizes numerous variab ...

Angular material checkbox showing incorrect behavior when in an indeterminate state

I am currently using Angular 7 along with Angular Material 7.3.7, and I am facing an issue while trying to create an unordered list of mat-checkbox. The problem I am encountering is that the indeterminate state is not consistently displayed as expected. Be ...

What are some strategies for creating a distinctive list design using markup?

Possible Duplicate: Achieving sub numbering on ol items html I am attempting to create a format similar to the one below using an unordered list: 1. Title Objective: some text here... 1.1 option1 1.2 option2 1.3 option3 2. Title ...

Why is my data attribute not being updated by the jQuery.data() method?

Here is an example of HTML code: <div id="mydiv" data-hoo-foo="bar"></div> As illustrated above, I am attempting to achieve the following: var $mydiv = $('#mydiv'); $mydiv.data('hoo-foo'); // returns 'bar&apos ...

Tips for inserting text into the description field on Shopify using Python Selenium

I am looking to build a bot using Python Selenium that can input the values I provide. I understand how to work with headings and select items, but I am unsure of how to paste text in a description field. For example: How can I paste text? I am unable to ...

CSS: Set the left position to 250px with the added feature of hiding any overflow

I am currently working on a sidebar that can be shown or hidden using JavaScript with CSS animations. To achieve this effect, I need to position the content div (#main) using left: 250px;. #main { left: 250px; position: relative; overflow: hidden; } ...

Creating a CSS grid with multiple rows and columns that expand dynamically

Currently, I am facing challenges with the layout of this CSS design. The number of items ("n") is dynamic and can increase indefinitely. My goal is to create a layout that consists of n rows and many columns (or an unlimited number of columns). For insta ...

Dimensions in Material UI

As I embark on my journey with Material UI components for React, I am facing the challenge of integrating pre-styled components into my project. I have noticed that some components appear too large in my layout due to excessive padding and margins. Curren ...

Aligning a Bootstrap button beneath text that is centered on the page

I want to include a button below some text in the contact section. The text reads "get in touch" at the center of the page, but when I add a button it appears under the text and aligned to the left. I need it to be centered on the page beneath the text. ...

Implementing a sticky header for tables using Bootstrap

I'm experiencing a conflict because the header remains fixed only when I include the table-responsive class in my code. However, I also need the table to have overflow. Can anyone provide assistance with this issue? Using the table-responsive class ...

Click at your own discretion button

<ul> <li> <span class="_1OSdk"> <button class="_5f5mN -fzfL KUBKM yZn4P ">Segui già</button> </span> </li> <li> <span class="_1OSdk"> ...

Looking to activate a bootstrap grid breakpoint when a div reaches a specified min-width

I have a webpage layout structured within a Bootstrap grid. In desktop view, one div (divDesktopDiv) is shown, and in mobile view, it is replaced by another div (divMobileDiv). However, my current setup causes the divDesktopDiv to overflow into the neighb ...

Automating dropdown selection in selenium: A guide to selecting options

Hey, I created a script to log in to github.com and open the dropdown menu. However, I am having trouble selecting the "sign out" option from the dropdown. I have tried using both the class name and xpath, but none of them seem to be working. Here's ...

I am experiencing issues with a few of my design choices not functioning correctly

I am facing issues with some of my styles. I have put in a lot of effort, but there seems to be a problem with my menu. The last part of my CSS is not functioning correctly. When hovering over the menu content, I want it to turn black and... #site_menu { ...

Display or conceal several elements upon hover using JQuery and HTML

Here is the current progress I have made: <div style = "position: relative;"> <a href = "#games"> <div class="sidenavOff"> <img src = "images/card_normal.png" /> <img src = "images/category_icons/icon_games.png" style = "positio ...

A loop that incorporates a jQuery JavaScript dropdown menu along with some calculations

My goal is to have multiple dropdown lists populated from a PHP while loop. Each select dropdown has a corresponding textbox that should update its value when a selection is made. However, the current script only works for a single dropdown outside of the ...

The functionality of Jquery dynamic form is not functioning properly

I attempted to create a dynamic form using Jquery based on the code provided at http://jsfiddle.net/pixelentity/aABLD/24/. I have implemented the HTML file accordingly. However, the form does not work as intended - it displays the HTML page but fails to sh ...

What is the process of connecting to an Embed object in HTML?

How can I create a HTML link for an Embed object that displays a video stream, so that when a user clicks on the link, it opens another window to show the video? <embed id="player" src="http://media2.wtnh.com/_local/livestreams/FMLPlayer.swf" align="ce ...

XPath was ineffective in selecting the product name text

Looking to locate the text "Native Starter Pro With Backend" using XPath. The structure of the HTML code is as follows: <tr> <td style="text-align:left;vertical-align:middle;border:1px solid #eee;word-wrap:break-word"> ...