How do I find an element that contains specific text in Selenium WebDriver (Python)?

I’m trying to test a complicated JavaScript interface with Selenium (using the Python interface, and across multiple browsers). I have a number of buttons of the form: <div>My Button</div> I’d like to be able to search for buttons based on “My Button” (or non-case-sensitive, partial matches such as “my button” or “button”). I’m finding this … Read more

Is there a way to get element by XPath using JavaScript in Selenium WebDriver?

I am looking for something like: getElementByXpath(//html[1]/body[1]/div[1]).innerHTML I need to get the innerHTML of elements using JS (to use that in Selenium WebDriver/Java, since WebDriver can’t find it itself), but how? I could use ID attribute, but not all elements have ID attribute. [FIXED] I am using jsoup to get it done in Java. That … Read more

Debugging “Element is not clickable at point” error

I see this only in Chrome. The full error message reads: “org.openqa.selenium.WebDriverException: Element is not clickable at point (411, 675). Other element would receive the click: …” The element that ‘would receive the click’ is to the side of the element in question, not on top of it and not overlapping it, not moving around … Read more

Get HTML source of WebElement in Selenium WebDriver using Python

I’m using the Python bindings to run Selenium WebDriver: from selenium import webdriver wd = webdriver.Firefox() I know I can grab a webelement like so: elem = wd.find_element_by_css_selector(‘#my-id’) And I know I can get the full page source with… wd.page_source But is there a way to get the “element source”? elem.source # <– returns the … Read more

Call a Class From another class

Suposse you have Class1 public class Class1 { //Your class code above } Class2 and then you can use Class2 in different ways. Class Field public class Class1{ private Class2 class2 = new Class2(); } Method field public class Class1 { public void loginAs(String username, String password) { Class2 class2 = new Class2(); class2.invokeSomeMethod(); //your … Read more

How to open a new tab using Selenium WebDriver in Java?

Just for anyone else who’s looking for an answer in Ruby, Python, and C# bindings (Selenium 2.33.0). Note that the actual keys to send depend on your OS. For example, Mac uses CMD + T, instead of Ctrl + T. Ruby require ‘selenium-webdriver’ driver = Selenium::WebDriver.for :firefox driver.get(‘http://stackoverflow.com/’) body = driver.find_element(:tag_name => ‘body’) body.send_keys(:control, ‘t’) driver.quit Python from selenium import webdriver … Read more