"value error: Element locator did not match any element." while trying to locate a element - robotframework

I am using Robot Framework with Selenium2Library for website tests automation. My HTML Value is
<select class="autoWidth m![Element Locator Error][1]inWidth" id="ctl00_ResultPanePlaceHolder_ctl00_ctl02_ctl01_contentContainer_ddlLanguage" name="ctl00$ResultPanePlaceHolder$ctl00$ctl02$ctl01$contentContainer$ddlLanguage">
<option value=![enter image description here][2]"1118">አማርኛ ‎(ኢትዮጵያ)‎</option>
I am using cmd
Click Element id=ctl00_ResultPanePlaceHolder_ctl00_ctl02_ctl01_contentContainer_ddlLanguage
I am getting
value error: Element locator did not match any element.
How to fix this issue.

Most likely your element is inside an iframe. Look through the html to see if you see <iframe ...> before the element you are trying to click. If so, you first need to use Select Frame before trying to click on the element.

You should need to use id= as ID is one of the default attributes it looks for. Is it possible to see some more of the html code surrounding the element you are after?

Related

selenium robot framework -how to get element description

I'm new on RobotFramework and have an issue as below.
Can someone help me on this?
<div id="cdk-describedby-message-41" role="tooltip">Open</div>
I would like to get "Open" from this element locator
I tried to use:
${des} Get Element Attribute //*[#id="${cdk-describedby-message-41}"] role
Log To Console ${des}
It would print out "tooltip"
Thanks a lot!
Well, first of all, it's not a description it's an element value!
Then you're using Get Element Attribute keyword. Attributes in this element are id and role, you should use Get Text keyword instead!
Here is a answer! How to get web element value and compare it with a number in Robot Framework?
I resolved my issue:
${des} Get Element Attribute //*[#id="${cdk-describedby-message-41}"] textContent

How to find checkbox with robot framework?

i'm trying to get the locator of a checkbox named mycheckbox.
i tried:
//div[#class='ng-binding','mycheckbox']
It doesn't find the checkbox
The html code is:
<label ng-attr-for="{{ guidedNavigationFilter.id + '_ctrl_' + $index }}"
ng-bind="choiceLabel" class="ng-binding"
for="groupRadioClassification de privilège_ctrl_2">
mycheckbox
</label>
Thank you for your help.
You are searching for a div tag, but the element you want is a label. Maybe you need to reference the div containing the label element. It could look like this:
//div/label[#class='ng-binding']
or
//div/label[.='mycheckbox']
The element you see "looks" like a checkbox, but it is something that is dynamically controlled by AngularJS.
You did not posted the exact keyword and error message, so it is harder to guess the solution. I would say to try to Focus or Click the element, so it is activated as a Checkbox.

selecting specific link from ng-repeat CSS using robot framework

Webpage opens one popup, in that popup I have a list of pets. like dog, cat, fish, etc. each element is a link, and defined as below in css. but all of them have same values for all of the attributes, like div class, ng-bind, ng-click, etc. only one difference is text. I am not getting how to select a specific value using this text.
Both of the images are attached for reference. you can check the CSS code as well as the application popup.
Application popup
Css Code
Please help me out....
In the below xpath example I'm assuming that this list is uniquely referenced using the #ng-repeat attribute and with that the following reference will become a unique one: //div[#ng-repeat='category in allCategory' and text() = 'Cow/Bull']
Partial matching of the text with xpath, just a little modification to the first answer.
//div[contains(text(),'Cow/Bull') and #ng-repeat="category in allCategory"]

How do I locate elements in protractor that are in other views and are not visible when viewing page source

I am new to Angular & Protractor (and web development for that matter), so I apologize of this is an obvious question.
I am trying to test our angular app with protractor, and it appears that I can locate the first element on the page. But cannot find any of the other elements using (id, name, model, css). I have tried chaining off of the first element, but always get the element not found error on the second element in the chain. I've have triple check the spelling so I am confident everything is correct.
Our page is setup up with multiple sections and when I "view source" I only see the root div.
<head>
</head>
<body>
<div ng-app="app" id="wrap">
<div ui-view></div>
</div>
</body>
</html>
But when I inspect the elements using the developer tools (F12), they exist in the DOM, I just don't know how to get to them.
<input type="text" class="form-control ng-valid ng-dirty ng-valid-parse ng-touched" data-ng-model="vm.searchText" id="searchText" placeholder="(Account # / Name / Nickname / Phone #)">
I tried to access the control listed above using the following:
browser.element(by.id("searchText").sendKeys("test");
browser.element(by.model("vm.searchText").sendKeys("test");
element(by.id("searchText").sendKeys("test");
element(by.model("vm.searchText").sendKeys("test");
I also create a single button and used partialButtonText & buttonText, neither of which worked.
I also tried to add some async functionality with "then" but that didn't work either. How do I access these elements are are not contained in a single html file?
thanks.....
If an element is not visible, I believe protractor isnt able to interact with it. It can't click or get text or anything if it is not visible, that is actually checked before it can perform the action.
What you can do is check the element is present to ensure it is somewhere on the html.
var searchText = $('#searchText');
expect(searchText.isPresent()).toBeTruthy('Search Text element not present');
This will find an element with a css selector of id searchText, and then check if it is present(exists on the html).
If you want to interact with it, remember that protractor looks around like a human would. If a human cant click it, neither can protractor! Make sure it is on the page and visible.
Don't have the reputation points to add this in the comments to user2020347's response so...When you say not in "view source" I assume you're talking about dynamically generated content. Instead of using view source either use chrome or firefox developer tools to make sure you're using the right locators.
For example in chrome's console the following should return a result once the page is loaded:
$$('#searchText')
$$('input[data-ng-model="vm.searchText"]')
It also looks like you're sending keys to the same element.
Since you have an angular app protractor should wait for all elements to load, but just in case you might want to wait for the element to be present and/or visible on the page.
Same happened to me, because Protractor executed on the original (first) tab.
Try to switch between the tabs before accessing the elements:
browser.getAllWindowHandles().then(function (handles) {
browser.driver.switchTo().window(handles[1]);
});

Simple HTML Dom get href that begins with

I am using Simple HTML Dom to extract information from a remote source. I would like to get all href links that contain a particular piece of text (not all on a page). I have tried
->find('a[href*="/place"]')
and
->find('a[href="/place"*]')
and
->find('a[href="/place*"]')
but this returns empty results.
The href I am trying to get must begin with the text "/place".
Any suggestions?
Thanks
Match elements that have the specified attribute and it starts with a certain value, use [attribute^=value].
->find('a[href^="/place"]')
Ref: http://simplehtmldom.sourceforge.net/manual.htm#frag_find_attr
I do not now this app, however did you try using the asterisk like so ?
>find('a[href="/place*"]')

Resources