Press the dynamic div element within the frame by utilizing Java Selenium WebDriver

How do I interact with a menuitem in one frame to display a dashboard in another frame?

<html>
   <head>
   <frameset scrolling="no" framespacing="0" marginwidth="0" marginheight="0"     border="0" frameborder="0" rows="98,*">
         <frame scrolling="no" noresize="" marginwidth="0" marginheight="0" src="menu.jsp" name="menu">
          <script language="JavaScript">
          <script type="text/javascript" src="menu7_com.js" language="JavaScript">
              <div style="position: absolute; display: block; background-color: black; width: 1080px; height: 18px; z-index: 1101; top: 72px; left: 10px;">
              <div style="position: absolute; overflow: hidden; cursor: default; color: rgb(0, 0, 0); font-family: Arial;font-size: 9pt; font-weight: bold; font-style: normal; background-color: rgb(224, 224, 224); text-align:left; width: 110px; height: 16px; padding-left: 10px; padding-top: 2px; left: 0px; top: 0px;">
              <div style="position: absolute; overflow: hidden; cursor: default; color: rgb(0, 0, 0); font-family: Arial;           font-size: 9pt; font-weight: bold; font-style: normal; background-color: rgb(224, 224, 224); text-align:            left; width: 110px; height: 16px; padding-left: 10px; padding-top: 2px; left: 120px; top: 0px;">
    </div>      
        <frame scrolling="auto" style="scrollbar-base-color:blue;" noresize="" marginwidth="0" marginheight="0" src="Dashboard.do?action=DashBoard" name="display">
         <div style="position: absolute; overflow: hidden; cursor: default; color: rgb(0, 0, 0); font-family: Arial;            font-size: 9pt; font-weight: bold; font-style: normal; background-color: rgb(224, 224, 224); text-align:left; width: 110px; height: 16px; padding-left: 10px; padding-top: 2px; left: 120px; top: 0px;">
     </div>
   </frameset>
</html>

Answer №1

It was noted that the specific element only becomes visible once the 'Parent Div tag' is clicked on. To interact with this element, you must first hover over its parent Div and then click on the child element. The Action class can be utilized to navigate to the parent element and perform a click action on the child. The correct Xpath for the Child Div tag has been provided, and a similar approach can be used to obtain the Xpath for the parent Div tag.

Here is an example illustrating the process:

        WebElement Parent_element= driver.findElement(By.xpath("Xpath of Parent Div Tag"));
        WebElement Child_element= driver.findElement(By.xpath("//div(contains(text(),'Create Hierarchy'))"));
        Actions action = new Actions(driver);
        action.moveToElement(Parent_element).click(Child_element).perform();

Answer №2

Apologies for the confusion, it turns out that the divs are located in separate frames. However, I was able to find a solution.

driver.switchTo().frame("menu");
WebElement MenuOne = driver.findElement(By.xpath("html/body/div[1]/div[1]"));
MenuOne.click();
driver.switchTo().defaultContent();
driver.switchTo().frame("display");
WebElement Createborrower = driver.findElement(By.xpath("html/body/div[5]/div[3]"));
Createborrower.click();

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 way to incorporate markers into my d3 line chart that includes two separate datasets?

In my JavaScript code, I'm creating a line chart for two datasets using the d3 library with Vue framework integration. Within the HTML code, there are buttons that trigger the updateData function to display the line charts for the respective datasets ...

Angular's focus function poses certain challenges that need to be addressed

I am seeking assistance as a new programmer facing a beginner's challenge. I have two inputs and I would like to enter a series of numbers in the first input (DO) and have them automatically populate in the second input (communal code). Inputs: http ...

Automatically scroll a div when the internal div is in focus

I want to create a scrollable div that allows for scrolling even when the mouse is over the content inside the div, not just on the blank areas beside it. Here is the code I am currently using: var main = document.getElementById('main-site'); va ...

Why does exporting 1 Selenium IDE script in Python 2.7 result in a blank Firefox page?

Trying to run a single test script exported from Selenium IDE 3.4 successfully in Python 2.7 with Firefox 53.03 (64 bit) and Geckodriver 0.16 on my Windows 7 Enterprise local machine. Here are the steps to reproduce: Export the test case from Selenium I ...

Sending a variable to the resize() function in jQuery

Currently, I am working with two specific divs in my project: "#sidebar-wrapper" and ".j1". The height of ".j1" is dynamic as it changes based on its content. My objective is to set this height value to the "#sidebar-wrapper" element. I have attempted to ...

Adapt the dimensions of the iframe to perfectly match the content within

Looking for a way to dynamically adjust the size of an iframe to perfectly fit its content, even after the initial load. It seems like I'll need some kind of event handling to automatically adjust the dimensions based on changes in the content within ...

Bringing in More Blog Posts with VueJS

Exploring the Wordpress API and devising a fresh blog system. As a newbie to VueJS, I'm intrigued by how this is handled. The initial blog posts load as follows: let blogApiURL = 'https://element5.wpengine.com/wp-json/wp/v2/posts?_embed&p ...

Extract specific elements from an array using Mongoose's $slice operator while still maintaining the

Currently, my task is to retrieve the total number of items in my News object and return a portion of those items as objects. While I have successfully implemented the $slice operator in my query, I am struggling to determine the original array size of the ...

Pull data from one array of objects using the id from another array to display in a list using AngularJS ng-repeat

After retrieving a list of options, I make an API call to validate each option. The goal is to display whether each option is valid or not. My starting array looks like: $scope.preValidationArray = [ { id: 1, description: 'Item 1' }, { id: 2 ...

What is the process for dynamically declaring a variable within the data function in Vue.js?

Looking for a solution where I can have the ability to dynamically add input fields to a form. Currently, my form consists of three input fields - name, email, and phone. However, I would like users to be able to add more input fields as needed. In order t ...

When using driver.quit() in Selenium on multiple driver objects, a ConnectionRefusedError may occur

I have a unique script that allows for the generation and execution of multiple chromedriver objects using selenium. These driver objects are stored in a dictionary with numeric values as keys to access them. In an attempt to quit specific drivers individu ...

Issue with IE due to jQuery/JavaScript conflict

After selecting one of the two radio buttons, I want to increment the total by $10. If the other option is selected, I want to revert back to the original total price. The jQuery function I am currently using is as follows: function check_ceu() { var ...

jQuery Issue - Clash between multiple menus sharing the same class

Hey there! I'm currently diving into the world of jQuery and encountering an issue with my menu. Whenever I click on a menu item with either the "tm-nav-vertical" or "tm-nav-horizontal" class, it removes the .active class from the initial menu item. I ...

Utilizing the Java Script SDK for Facebook API to Publish Actions

I've been encountering difficulties with the Facebook API. I have created an app, an object, and an action, and I'm trying to test publishing in my stream (I understand that public publishing needs authorization from Facebook, but as an administr ...

I am unable to incorporate the RobotJS module into my ElectronJS project

Currently, I am working on a Windows desktop application using ElectronJS. My main challenge is integrating the RobotJS module into my project. Despite successfully downloading the module with 'npm install robotjs' and incorporating it into my ma ...

The next.js application utilizing a custom server is experiencing rendering issues

Expanding my knowledge to next.js, I might be overlooking a simple aspect. My goal is to implement custom routes, so I crafted a server.js file and adjusted the command in my package.json to node server.js. Below is the entirety of the server.js file: con ...

Encountering empty values when retrieving data from a JavaScript array

Upon receiving a response in the form of a JavaScript Object, the structure looks something like this: { "result": [ { "invoice_prefix": "INV", "maximum_invoice_no": "0009" } ] } I am attempting to access t ...

Tips for specifying which project starts the setup process in Playwright

I have multiple projects in my playwright.config file, all of which have the same setup project as a dependency. Is there a way to determine at runtime which parent project is initiating the setup process? playwright.config projects: [ { name: " ...

Analyzing a tweet containing unique characters

I am currently working on extracting links from tweets, particularly hashtags and mentions. However, I have encountered an issue when the tweets contain special characters like " ...

Tips for enhancing the efficiency of my JavaScript code?

On my page, I have a list of items with various actions assigned to them. One can either click on an icon next to each item or check a checkbox on the left side. However, when clicking on an action after selecting multiple items, there is a noticeable lag ...