In robotium4.3, how can click on a webelement? - robotium

In robotium4.3, how can click on a webelement. So far, I can click on a webelement by locationx and locationy. But it dose not work by webid or other arguments.
Is there anybody can help me with this problem? TKS!!

There are methods clickOnWebElement in Solo class. There is By class which can be used to find element. For instance:
solo.clickOnWebElement(By.className("button"));
By implementation you can find here

Related

How to interact with shadow-root DOM element in Chrome with VBA

I am trying to interact element in this page but I can't, I figured out it happened because #shadow-root.
But, I still don't know how to interact with these thing.
Also, I would like to know the way to make its work with VBA
This is the link for example : https://books-pwakit.appspot.com/
Thanks
element=driver.ExecuteScript(
"return document.querySelector('csslocator').shadowRoot.querySelector('csslocator')")
you have to find the root element that has the shadoow root and then call shadowRoot on it and then call querySelector again to find specfic element inside it
This is because shadowdom is not part of DOM

How to locate elements in AG-Grid? if there is no ids available

I’m facing a challenge in locating the elements in AG Grid. As I unable to locate the elements in the grid. Can we create the user define locator in selenium to locate the elements in AG Grid. Or Kindly suggest any other alternative to work with it. And it is prohibited to use either of the locators xpath, css selector, name, class in our project.
One more thing, is it possible to .
Kindly refer to the attached screenshots for the reference. Do let me know if you need any further information from my side.
Any help would be highly appreciated.
I tried locating the elements with other locators
below xpath should work,
//div[#col-id='locationName'][contains(text(),'Opthamology')]
If you cannot use anything but id - you should ask your application developers to add unique identifiers for each element.
If for some reason it is not possible - you can use WebDriver.executeScript() function which allows executing arbitrary JavaScript code which in its turn can evaluate various selector expressions, for example XPath, the relevant syntax for your case would be something like:
WebElement someElement = (WebElement) driver.executeScript("return document.evaluate('//div[contains(text(),\"Opthamology\")]', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;");

Behat to click on element by class or ID name?

Is it possible for behat to find an element by class name to click on? It looks like only the following is searched for: id|name|title|alt|value
For example, how could you successfully identify this element to click on?
<a class="button medium round signup" href="http://link.com" data-reveal-id="signupModal">sometext</a>
Also here is a simple page with a button, that has an ID. How come the following does not access the button?
<button id="myBtn" type="button" onclick="myFunction()">Try it</button>
Given I am on "http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_button_form"
When I press "myBtn"
Thanks
The button can not be accessed because it is contained in an iframe, you need to switch to that iframe to make the button available.
You can create steps to click on an element by any type of identifier (class included), or you can implement new step that requires css/xpath selectors.
Here you can find an example of a method to click by selector.
The first HTML code is nothing but a HREF. Behat should be easily able to identify it by using the line below:
Given I follow "sometext"
If the above doesn't work, you can simply use the CSS selector and click the element:
$locator = '.';
$this->getSession()->getPage()->find('css',$locator)->click();

Selenium By.linkText issues

So i am automating few tests for this one page, and using method "linkText" for finding element does not work even though it is clearly there,selector is written properly,element is visibile etc. Using its xpath does work however.
Any similiar experiences , ideas what may be the cause?
[Update]
WebElement element = driver.findElement(By.linkText("Sign up/login"));
<li class="n15-menu-arrow pull-right">Sign up/login
I see, can you please try partialLinkText?
WebElement element = driver.findElement(By.partialLinkText("login"));
or
WebElement element = driver.findElement(By.partialLinkText("Sign"));
If you locate a wrong element, that means in your HTML there are other elements happen to share this partial link text in their attributes, in that case, I recommend using Css Selector.

Locating elements in selenium IDE

I have tried to locate button in my web app using xpath but it changes automatically each time I open selenium IDE. Is there any other way to locate it except using xpath or position? can I locate it using class name? If yes then how can I do it?
You can use xpath to find element by class name.
//*[#class='someClass']
where, someClass is the class name of your element.
Since it is your webapp, consider adding an id or a name to uniquely identify the element. It also makes the xpaths easier to write as you don't need to consider the possibility where you might be grabbing too many elements.
Answer - If by default recorded xpath are not working for your application, then you can define your own xpath for those components which should remain same throughout execution.
Please refer below URL which shows ways to develop userdefined xpath :-
http://docs.seleniumhq.org/docs/appendix_locating_techniques.jsp
Use a CSS selector. This site really helped me: http://saucelabs.com/resources/selenium/css-selectors
if it has an id on it you can just say "id=yourid"
for css it could be something like this: "css=button[class*='yourclass']" <-- that says it's a button, and that in class it contains yourclass.