I am using python code such as below to click an element within an iframe on an angularjs page.
browser = webdriver.Ie()
browser.switch_to.frame('name')
browser.find_element_by_id('value').click()
After using click() I am unable to manually highlight text that appears on the page. Why might this happen? How can I restore the ability to highlight text with the mouse?
I have tried switching back to default content, but this makes no difference. Any ideas?
Other strange effects after using click(): Links and buttons don't work while using the mouse manually unless double-clicked. These would normally require single click. It is as if there is an invisible overlay blocking text selection or clicking links. Radio buttons and menus still work.
Edit: The site uses silverlight and I am wondering if this is related to the problem that results from using click().
Related
Apologies if this question was answered before, I want to click on an area in a browser with plain text using Selenium Webdriver in python
The code I'm using is:
element_plainText = driver.find_elements(By.XPATH, '//*[contains(#class, "WgFkxc")]')
element_plainText.click()
However this is returning "ElementNotInteractableException". Can anyone help me out with this?
Selenium is trying to be helpful here, by telling you why it won't click on the element; ElementNotInteractableException means it thinks that what you're trying to click on isn't clickable.
This usually happens because either:
The element isn't actually visible, or is disabled
Another element is "overlapping" the element, possibly invisibly
You're clicking something Selenium thinks won't do anything, like plain text
There's two things I'd try to get around this. Firstly, Actions. Selenium has an Action API you can use to cause specific UI events to occur. I'd suggest finding the co-ordinates of the text, then making Selenium click those co-ordinates instead of telling it to click the element. Read more about that API here.
Secondly, try clicking it with Javascript, using a Javascript Executor. That can often give you the same outcome as using Selenium directly, without it being so "helpful".
I am trying to write a code that opens a website and performs different tasks. Some buttons don't have any selectors (i believe it is called), when I hover over them with my mouse using the inspect tool, nothing comes up. Is it possible to click on these buttons in any different way using python and selenium? For example by telling selenium to click on specific locations on the screen?
so i am trying to make a selenium browser where i could save the xpaths of elements underneath the mouse cursor or the location of a click.
I have had a look around and have not found anything related to the topic, Nor have i found any such function to get me the Xpath Underneath or at a click.
This will allow me to manually save little selenium functions which could be exported and re ran.
I have a web page with more few buttons with same class and name and when clicked they just disappear and do nothing. So I first tried this but it didn't work:
buttons = driver.find_elements_by_xpath('//*[#class="btn"]')
buttons[1].click()
buttons = driver.find_elements_by_xpath('//*[#class="btn"]')
buttons[2].click()
buttons = driver.find_elements_by_xpath('//*[#class="btn"]')
buttons[3].click()
And then found a solution with:
buttons = driver.find_elements_by_xpath('//*[#class="btn"]')
buttons[1].send_keys('\n')
I am new to Python so can anyone explain me what is the reason for not working with click but with send_keys('\n')?
Depending on the WebElement type, some elements do not accept clicks even if the website intends for you to click them -- instead of sending keys, you could try using a Javascript click() function to see if that works. It's a bit more consistent than sending keys, because you are still performing a click:
buttons = driver.find_elements_by_xpath('//*[#class="btn"]')
# click button using javascript
driver.execute_script("arguments[0].click();", buttons[1])
The reason we need to use Javascript usually has to do with a limitation on the web page itself.
I have an issue when trying to test a web application with Selenium/Python. Basically I can't test elements of a pop-up window.
A scenario: I can test all elements for a page. But when I go to click on a button that opens up a small pop up box I can't test the elements on the popup. It's like the pop up isn't in focus or active.
I can test elements on the next page. For example click a button, brings me on to next page, and I can work with elements on the 'next' page. So it the problem seems to be popup specific.
I could post code but to be honest it might confuse at this stage. I may post code in a later post, thanks
There is a property called switch_to
Q: How do I handle pop up windows?
A: WebDriver offers the ability to cope with multiple windows. This is done by using the WebDriver.switch_to.window(knownName) method to switch to a window with a known name.
If the name is not known, you can use WebDriver.window_handles to obtain a list of known windows.
You may pass the handle to switch_to.window(handleName)
For example I used driverName.switchTo.window(driverName.getWindowHandle()) to get a hold of popups for which I didn't want to look for names.
Additional references:
http://code.google.com/p/selenium/wiki/FrequentlyAskedQuestions
For the Selenium RC API, you need to use the SelectWindow command to switch to the pop-up window. The window can be specified either by its name (as specified on the JavaScript window.open() function) or its title. To switch back to the main window, use SelectWindow(None).