I am trying to click on right click menu and i am able to open the right click menu but its not clicking on any menu or not pressing any keys like down , up etc where i am wrong :
profile_pic=driver.find_element_by_css_selector('img[class="profilePic img"]')
okl=profile_pic.click()
time.sleep(5)
action1=ActionChains(driver)
action1.context_click(okl).send_keys(Keys.ARROW_DOWN).send_keys(Keys.ARROW_DOWN).send_keys(Keys.ENTER).perform()
here is a working version to do it:
first right click to show up the menu
menuDiv = browser.find_element_by_xpath("//<selector>']")
actionChains.move_to_element(menuDiv).perform()
actionChains.context_click().perform()
then locate the submenu item you want to click on
time.sleep(3) //better wait for a little while
targetMenu = browser.find_element_by_xpath("//<selector>")
actionChains.click(targetMenu)
actionChains.perform()
Related
The element isn't being recognized, I'm trying to click the button after I put in a file submission. I tried having the keyboard press enter as an alternate solution but it doesn't work.
Image of HTML
def ClickButton():
action = ActionChains(web)
button_path = wait.until(ec.presence_of_element_located((By.XPATH,"//*[local-name()='svg' and #data-qa='send-message']/*[localname()='path']")))
# click the item
action.move_to_element(button_path)
action.click(on_element=button_path)
# perform the operation
action.perform()
Try CSS:
button = driver.find_element_by_css_selector('svg[size="24"] \
[data-qa="send-message"] \
[data-button-disabled="false"]')
button.click()
I am new to python and selenium. I am trying to click a button in a formbox, but cannot click, only highlight the button. I am trying to click on the button named "Delivery System"
My code is:
delivery_system = browser.find_element_by_name("Delivery System")
browser.execute_script("arguments[0].click();", delivery_system)
delivery_system.click()
The html is:
HTML Code
When I try my code it just highlights the button, but doesn't click/follow it?
ANy ideas?
i would advice you change
delivery_system = browser.find_element_by_name("Delivery System")
browser.execute_script("arguments[0].click();", delivery_system)
delivery_system.click()
to
delivery_system = browser.find_element_by_name("Delivery System").click()
or select by classname
driver.find_element_by_css_selector('.browseLink').click()
The exact button I am trying to click is this:
https://www.bungol.ca/map/location/toronto/?
close the property slider on the left
click tool -> open list
click on any of the listing and you get to something like this:
Image for close button
Here's what I tried to do:
time.sleep(5) #wait for page to fully load
driver.find_element_by_xpath("""/html/body/div[17]/div/div/div/button""").click()
and
time.sleep(5) #wait for page to load
driver.find_element_by_css_selector("""html body#body.modal-open div#listingInfoModal.modal.fade.show div.modal-dialog.modal-xl div.modal-content div.modal-body button.close""").click()
This CSS selector will do it.
#listingInfoModal button.close
I'v like to ask if there is any possibilities to click in submenu of contextmenu.
Basic click on some of manuitem is basic (example of code):
app = Desktop(backend='uia').window(best_match='ItemTemplates')
win = app.window(best_match='Visual Web Developer')
win.click_input(button='right')
app = Desktop(backend='uia').window(best_match='Context')
win = app.window(best_match='Send To')
win.click_input()
In this code i will right click element of explorer, then click to ,,Send to" all elements of right click menu are in u'Context'. Submenu items are a mystery.
Example
I need to do the following:
1) Right click on a element
2) Context menu is displayed
3) On moving
to a specific menu (move_to_element) in context menu - pops up
another menu say MenuX
4) Need to click on MenuX
I am able to do steps 1 to 3 but not 4.
When I checked is_displayed for MenuX it returns False
When I try driver.find_element_by_xpath("html/body/div[5]/span[2]")
it works (I do not want to hardcode).
But not with id of menu.
Also tried but no luck
actions = ActionChains(driver)
actions.move_to_element(menu)
actions.click(hidden_submenu)
actions.perform()
I also tried driver.find_element_by_css_selector("div#contextMenu_Div #menuX") and it didn't work.
MenuX is not link but a span element.
Try to use below code in order to click on the sub menu item after right clicking:
WebElement element = driver.findElement("Find the element on which right click needs to be performed"));
Actions actions = new Actions(driver).contextClick(element);
WebElement mainMenu = driver.findElement(By.linkText("menulink"));
actions.moveToElement(mainMenu);
WebElement menuX = driver.findElement(By.cssSelector("subLinklocator"));
actions.moveToElement(menuX);
actions.click().build().perform();
Hope this helps
Can you try this..
Actions actions = new Actions(driver);
actions.contextClick(mainelement);
actions.moveToElement(menuelement);
actions.perform();
//at this point ur MenuX shd be visisble.
driver.findElement("locator for ur MenuX").click();