Pywinauto click on item in submenu of context menu - python

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

Related

radio button in google form with selenium python

I was writing a web scraper in python using selenium on a google form page, but i want to be able to select a particular button that i want. i tired selecting all the buttons once so it ended up selecting the last one as expected. Going through a multiple of a number is also not possible as each contain different number of buttons.
So i want a way to get the number of radio buttons in a group and a way to select the desired one.
Test site
If there are any other suggestions then i will be happy to listen ?
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
import Resources
from selenium.webdriver.support.select import Select
driver = webdriver.Chrome(executable_path= Resources.driverChrome)
driver.maximize_window()
driver.get(Resources.linkTest)
time.sleep(3)
try:
email = driver.find_element_by_xpath("//input[#type='email']")
if email.is_displayed() & email.is_enabled():
email.send_keys(Resources.emailTest)
except:
print("Email box was not found")
containers = driver.find_elements_by_xpath("//div[#class ='freebirdFormviewerViewNumberedItemContainer']")
sNoBoxes = driver.find_elements_by_xpath("//input[#type='text' ] ")
time.sleep(2)
radios = driver.find_elements_by_xpath("//div[#class='appsMaterialWizToggleRadiogroupOffRadio exportOuterCircle']")
for radio in radios:
radio.click()
for container in containers:
sNo = int(containers.index(container))
print("\n\n" + str(sNo) + " " + container.text)
button = driver.find_element_by_xpath("//span[contains(text(),'Submit')]")
button.click()
time.sleep(3)
try:
viewScore = driver.find_element_by_xpath("//span[contains(text(),'View score')]").click()
except:
pass
First, you can find all radio buttons on the webpage with the following code:
radiobuttons = driver.find_elements_by_class_name("appsMaterialWizToggleRadiogroupElContainer")
Result: a list of radio button elements
Next, you are going to count the radio buttons. Note that radio buttons are global; The radio button "Option 2" is the 11th button instead of 2nd. If you want to click the very first radio button, use:
radiobuttons[0].click()
Result: the radio button is clicked
To click the n th radio button, use:
radiobuttons[n-1].click()

Clicking a Button in a formbox with selenium WebDriver in python

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()

How click on right click menu in selenium python?

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()

How to click on a context menu- popup menu

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();

How to select text from textbox in ios app and click on text using appium

I can write text to textbox in iOS app using appium as
editTextBox = driver.find_element_by_xpath("....")
editTextBox.send_keys(text)
The text is web link, how can I click on link?
I think I can select text and then click?

Categories

Resources