InvalidSelectorException while trying to identify web element in robot framework - xpath

ign-In | FAIL |
InvalidSelectorException: Message: The given selector xpath=//*[#id='user_email'] is either invalid or does not result in a WebElement. The following error occurred:
InvalidSelectorError: Unable to locate an element with the xpath expression xpath=//*[#id='user_email'] because of the following error:
TypeError: The expression cannot be converted to return the specified type.
Stacktrace:
at FirefoxDriver.annotateInvalidSelectorError_ (file:///var/folders/5f/6mvs5x1j37s5q3_38kjfwkgr0000gn/T/tmp1Nrpuj/webdriver-py-profilecopy/extensions/fxdriver#googlecode.com/components/driver-component.js:10633)
at FirefoxDriver.prototype.findElementsInternal_ (file:///var/folders/5f/6mvs5x1j37s5q3_38kjfwkgr0000gn/T/tmp1Nrpuj/webdriver-py-profilecopy/extensions/fxdriver#googlecode.com/components/driver-component.js:10691)
at FirefoxDriver.prototype.findElements (file:///var/folders/5f/6mvs5x1j37s5q3_38kjfwkgr0000gn/T/tmp1Nrpuj/webdriver-py-profilecopy/extensions/fxdriver#googlecode.com/components/driver-component.js:10695)
at DelayedCommand.prototype.executeInternal_/h (file:///var/folders/5f/6mvs5x1j37s5q3_38kjfwkgr0000gn/T/tmp1Nrpuj/webdriver-py-profilecopy/extensions/fxdriver#googlecode.com/components/command-processor.js:12534)
at DelayedCommand.prototype.executeInternal_ (file:///var/folders/5f/6mvs5x1j37s5q3_38kjfwkgr0000gn/T/tmp1Nrpuj/webdriver-py-profilecopy/extensions/fxdriver#googlecode.com/components/command-processor.js:12539)
at DelayedCommand.prototype.execute/< (file:///var/folders/5f/6mvs5x1j37s5q3_38kjfwkgr0000gn/T/tmp1Nrpuj/webdriver-py-profilecopy/extensions/fxdriver#googlecode.com/components/command-processor.js:12481)

This part of the error message explained why :
The given selector xpath=//*[#id='user_email'] is either invalid or does not result in a WebElement.
In this case, //*[#id='user_email'] is valid XPath expression, so it must be no element matched by that XPath. That's all I can tell from the information provided.

Related

Get value of aggregate xpath function in Selenium Java

I'm trying to get the index of a <tr> element based on the contents of its <td> elements in Selenium using xpath.
String xpath = "count(//tr[td[text()='Column Value A'] and td[text()='Column Value B']]/preceding-sibling::*)"
WebElement count = driver.findElement(By.xpath(xpath))
However, I'm getting this exception.
org.openqa.selenium.InvalidSelectorException: invalid selector: Unable to locate an element with the xpath expression count(//tr[td[text()='Column Value A'] and td[text()='Column Value B']]/preceding-sibling::*) because of the following error:
TypeError: Failed to execute 'evaluate' on 'Document': The result is not a node set, and therefore cannot be converted to the desired type.
Is there any way for Selenium to return the value of an aggregate xpath function?
Thanks in advance for your help!

ImageSegmentationAnnotation Class seems to not work while giving the path to the annotations BitMaps

I am not able to figure out correct Key, Value names to pass out bitmap labels to a Image Segmentation problem in vertex AI. My error message is below:
Error: Could not parse the line, json is invalid or the format does not match the input schema: Cannot find field: ImageSegmentationAnnotation.MaskAnnotation in message google.cloud.aiplatform.master.schema.ImageSegmentationIoFormat. for: gs://starry-embassy-363916-image/Figaro1k_json.jsonl line 3
Error: Could not parse the line, json is invalid or the format does not match the input schema: Cannot find field: ImageSegmentationAnnotation.MaskAnnotation in message
And the format of the .jsonl file I am giving is :
{"imageGcsUri": "gs://starry-embassy-363916-image/Figaro1k/Original/Training/Frame00003-org.jpg", "ImageSegmentationAnnotation.MaskAnnotation" : [{"mask_gcs_uri": "gs://starry-embassy-363916-image/Figaro1k/GT/Training/Frame00003-gt.pbm"}], "dataItemResourceLabels": {"aiplatform.googleapis.com/ml_use": "training"}}
TIA
I tried various combination of the ImageSegmentationAnnotation class as documented here:
https://cloud.google.com/vertex-ai/docs/reference/rpc/google.cloud.aiplatform.v1/schema#google.cloud.aiplatform.v1.schema.ImageSegmentationAnnotation
And here:
https://cloud.google.com/vertex-ai/docs/image-data/classification/prepare-data#json-lines_1

I'm trying to get the "id" of an html tag, but the xpath doesnt work

I'm using selenium and i want to get the "id" of an html tag with "find_elements_by_xpath", but i've got this error :
selenium.common.exceptions.InvalidSelectorException: Message: invalid
selector: The result of the xpath expression
"//body[contains(#class,'de')]/div/div[contains(#class,'container-fluid
default')]/section[contains(#id,'mainContent')]/div[contains(#class,'row-fluid')]/div[contains(#id,'contentContainer
row-fluid')]/div[contains(#class,'content')]/div[contains(#class,'ses')]/ul/li/#id"
is: [object Attr]. It should be an element.
When i executed this code:
browser.find_elements_by_xpath("//body[contains(#class,'de')]/div/div[contains(#class,'container-fluid default')]/section[contains(#id,'mainContent')]/div[contains(#class,'row-fluid')]/div[contains(#id,'contentContainer row-fluid')]/div[contains(#class,'content')]/div[contains(#class,'ses')]/ul/li/#id")
While the same code without "/#id" work perfectly but i've got only the text in the "li" tag and it's not what i want.
According to the error, the problem comes from the Xpath.
I expected that this code would return all the "id" that are in "li" html tag, but i got the error.
Thank you for your help
#id is an attribute, not an element. The XPath is OK, but the function only returns elements, not attributes. I doubt there's find_attributes_by_xpath, but if you want to find the li element that has the #id defined, you can specify that in the quantifier:
browser.find_elements_by_xpath("//body[contains(#class,'de')]
/div/div[contains(#class,'container-fluid default')]
/section[contains(#id,'mainContent')]
/div[contains(#class,'row-fluid')]
/div[contains(#id,'contentContainer row-fluid')]
/div[contains(#class,'content')]
/div[contains(#class,'ses')]/ul/li[#id]")
~~~~~
You can then call element.get_attribute('id') to retrieve the id of the element.

Using OCaml cohttp Client.post method

I'm trying to use the OCaml cohttp package to send a POST request using the Client.post method. I looked at the example in ocaml-cohttp/lib_test/test_net_lwt_client_and_server.ml to use the method, here's a code snippet from the example which uses the function.
Client.post ~body:(Cohttp_lwt_body.of_string "barfoo") url
I'm using the function exactly the same way in my own code:
Client.post ~body:(Cohttp_lwt_body.of_string bodyString) (Uri.of_string stringURI) >>= function
| Some (_, body) -> Cohttp_lwt_body.string_of_body body
| None -> return ""
But I get the error message:
Error: This pattern matches values of type 'a option
but a pattern was expected which matches values of type
Cohttp.Response.t * Cohttp_lwt_body.t
I looked at https://github.com/mirage/ocaml-cohttp/issues/64 which suggested changing the ~body label to ?body but then I got a different error:
Error: This expression has type Cohttp_lwt_body.t
but an expression was expected of type Cohttp_lwt_body.t option
Could someone please explain how to use this function correctly?
The error message indicates that this is a typing issue:
Error: This pattern matches values of type 'a option
but a pattern was expected which matches values of type
Cohttp.Response.t * Cohttp_lwt_body.t
Your function body to the right of the bind (>>=) should be rewritten to handle the tuple returned by Client.post rather than an option type. For example:
Client.post
~body:(Cohttp_lwt_body.of_string bodyString)
(Uri.of_string stringURI)
>>= fun (response, body) ->
match response with
| { Cohttp.Response.status = `OK; _ } -> ok_response_action body
| { Cohttp.Response.status; _ } -> other_response_action status body
cohttp does not, unfortunately, currently have easily accessible documentation. You would need to reference the .mli files from the source directly. For example, see here for information on the Cohttp.Response.t type's structure.

Getting error: **Enumeration yielded no results**

I'm getting the error Enumeration yielded no results while doing:
IEnumerable<Proxy> pxys = this._ticket.AllProxies.Where(p => p.IfBusy.Equals(false));
The reason you would get that error message is one of 2 reasons, either this._ticket.AllProxies contains no items (e.g. it is an empty collection) or none of the proxies in the collection have a value of false for their IfBusy property.

Resources