Guide on efficiently navigating a website: utilize selenium python to effortlessly hover the mouse over a sub menu and click on desired options

Seeking to automate a web application called "Maximo" using Selenium in Python, I've successfully managed to log in with credentials and click on buttons. However, I'm stumped on how to hover the mouse over a submenu and perform a click action.

I'm also exploring ways to invoke JavaScript corresponding to a menu displayed at the bottom of Maximo (image linked below).

View image description here
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select

browserchr3=webdriver.Chrome('C:\chromedriver\chromedriver.exe')
browserchr3.get('http://da-maximo.dca.com/maximo/webclient/login/login.jsp?welcome=true')
browserchr3.find_element_by_id('username').send_keys('bhsek015'+Keys.TAB)

userpassword=browserchr3.find_element_by_id('password')
userpassword
userpassword.send_keys('Adil@2020')
userpassword.submit()
#browserchr3.execute_script(topLevelMenus['m7f8f3e49_ns_mc'].menuClick({"id":"WOTRACK_APP","text":"Work Order Tracking","eventvalue":"WOTRACK","apptype":"RUN","target":"startcntr","event":"changeapp","value":"WOTRACK"}))
browserchr3.implicitly_wait(10)                      

Select(browserchr3.find_element_by_css_selector('#m7f8f3e49_ns_menu_WO_MODULE_a')).select_by_visible_text("Work Order Tracking")
wo
wo.click()
browserchr3.implicitly_wait(10)
wot=browserchr3.find_element_by_css_selector('#menuholdertd')
wot
wot.click()

Answer №1

When dealing with your first inquiry, which involves hovering over an element, utilizing Action Chains is necessary.

from selenium.webdriver.common.action_chains import ActionChains

actions = ActionChains(browserchr3)
# Assuming 'wot' represents the element to shift your mouse towards
actions.move_to_element(wot)
actions.perform()    #Carries out the chained action

You have the option to chain actions as follows: ActionChains(browserchr3).move_to_element(wot).perform()

In case you require a detailed reference, feel free to check the API => https://seleniumhq.github.io/selenium/docs/api/py/webdriver/selenium.webdriver.common.action_chains.html

Regarding your second question on executing JavaScript:

browserchr3.execute_script('Script statement')

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

Tips for modifying the hue of the hint attribute within vue.js?

`<v-text-field id="loginPasswordId" ref="password" v-model="password" class="login-input" dense :disabled="loading" :hint="hello world" :loading="loading" maxlength= ...

The web page's content remains hidden until it is scrolled into view, despite the fact that the page has finished loading

I'm a beginner with Angular and currently working on creating a website. On the following page , when viewed on mobile, I am experiencing an issue where the content doesn't load until it's brought into view by scrolling down the page. I am u ...

What could be the reason for the malfunctioning transition effect in my slider animation?

Having trouble getting my slider animation to work. I've tried different CSS styles but the slide transition is not functioning as expected. When one of the buttons is clicked, I want the slide to change from right to left or left to right. Can anyone ...

"Troubleshooting ng-submit in AngularJS: How to Fix a Function That

I've encountered an issue with my angular-promise where a http method is not being called when a form is submitted using ng-submit. There are no errors, but it seems like the function is never executed. Here's the JavaScript code snippet: myapp. ...

Fade-in loader with centered placement on the full page

As a newcomer to programming, I wanted to implement a loader that displays a centered loading animation when the page loads or refreshes. The animation should gray out and fade the entire page until it fully loads. I've managed to get everything else ...

Tips for displaying a loading indicator above a form

I've been struggling to figure out how to display a loading indicator on top of my form without messing up the styling... My goal is to show the loading indicator when any action, like deleting an item or changing quantity, is triggered in React.js + ...

Obtain the beginning and ending positions of a substring within a larger string

As a beginner in the world of AngularJS and web development, I am faced with a challenge. I have a specific string that is currently selected on a tab, like so: var getSelectedText = function() { var text = ""; if (typeof window.getSelection !== "un ...

Parallel assessment on android devices

I have successfully set up my selenium grid with appium and created drivers for two different android devices - d1 and d2. Now, I am looking to maintain synchronization between them. This means that the driver should perform operations using d1 and then sw ...

Is it possible for Nextjs routing catchAll to coexist with a slug folder within a route?

When converting my pages to ISR, I encountered an issue with handling params and dynamic routes. One example is where article/?pageNumber=2 needs to be rewritten as article/2 in middleware for improved performance. However, this change in routing structure ...

Handling routerLink exceptions in Angular 2, 4, and 5

In my app, I am working on catching routing exceptions. There are three ways in which a user can navigate: If the user types the address directly - this can be caught easily by using { path: '**', redirectTo: 'errorPage'} in the route ...

Use jQuery to display the first 5 rows of a table

I recently posted a query on show hide jquery table rows for imported xml data regarding how to toggle visibility of specific table rows using jQuery. Now, I am seeking advice on how to make the first 5 elements always visible within the same context. Belo ...

The link and source attributes are missing from the .ejs template

I am experiencing an issue where the href and src attributes in my .ejs file are not referencing my local files properly. My setup involves node.js and express. Here is a snippet from the .ejs template that is causing the problem. <head> & ...

Keep looping for printing screenshots

Looking for some assistance. I have a Python script that loads URLs and takes screenshots. Here's what I'm trying to accomplish: Instead of using an array, read URLs from a text file Take individual screenshots of each loaded URL and save them ...

Issue with function execution within useEffect() not being triggered

I am facing an issue where two functions in my component are not being called every time it renders, despite my efforts. Placing these functions in the dependency array causes an infinite loop. Can anyone identify why they are not executing? function Por ...

Modify the length of an array using a number input field

Currently, I am working with an array that contains objects and I want to dynamically change the number of objects in this array based on user input from a number type input box. Whenever the number in the input box is increased, I need to increase the len ...

Using ES6, when utilizing array map in ReactJS, the function does not produce a return value

One challenge I'm facing involves mapping an array to find a specific string value. Unfortunately, despite my efforts, the map function is not returning anything as expected. class Application extends React.Component { constructor(){ super(); ...

Are you utilizing Google Chrome extensions for importing and exporting JSON files?

Currently, I am in the process of developing a Google Chrome extension and I have a question regarding its capabilities. Is it possible for the extension to generate JSON files for users to download (export) as well as implementing a button that allows use ...

An unexpected error occurred: ReferenceError - document is undefined

Error Alert: Unhandled Runtime Error ReferenceError: doc is not defined Source of Issue components\Modal.js (42:18) @ updateDoc 40 | await uploadString(imageRef, selectedFile, "data_url").then(async (snapshot) => { 41 | const do ...

"Extracting items from a list and using them to locate elements with find_element

driver.find_element_by_xpath('//*[starts-with(@href, "javascript") and contains(@href, '"(list1)[3]"')]') I'm struggling with a piece of code similar to this. It's almost functional, but the issue arises w ...

Transferring information between components and pages within Next.js involves the passing of data

I currently have an index page set up like this: getServerSideProps(){ //Making two API calls here api1() api2() return{ props:{data:gotDataApi1, data2:gotDataApi2} } } The data retrieved from these APIs is then passed to a component within the index pag ...