Write Selenium and Appium tests in Python using the Page Object pattern. This Pythonic GUI and API test automation framework will help you get started with QA automation quickly. It comes with many useful integrations like - email, BrowserStack, Slack, TestRail, etc. This repository is developed and maintained by Qxf2 Services.
UnicodeEncodeError: 'charmap' codec can't encode character '\x80' in position 15: character maps to <undefined> generated for following 3 websites while generating xpaths using xpath_util.py #276
Rahul Bhave Qxf2@LAPTOP-S0A7MKF0 MINGW64 ~/code/rahul-qxf2/issue_215/qxf2-page-object-model (issue_239_xpath_util_exception)
$ python utils/xpath_util.py
Start of utils/xpath_util.py
Enter URL: http://stackoverflow.com
Traceback (most recent call last):
File "utils/xpath_util.py", line 177, in <module>
if xpath_obj.generate_xpath(soup) is False:
File "utils/xpath_util.py", line 50, in generate_xpath
print ("%s_%s = %s"%(guessable_element, variable_name.encode('utf-8').decode('latin-1'), locator.encode('utf-8').decode('latin-1')))
File "C:\Program Files\Python38\lib\encodings\cp1252.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\x80' in position 15: character maps to <undefined>
(venv3)
Rahul Bhave Qxf2@LAPTOP-S0A7MKF0 MINGW64 ~/code/rahul-qxf2/issue_215/qxf2-page-object-model (issue_239_xpath_util_exception)
$ python utils/xpath_util.py
Start of utils/xpath_util.py
Enter URL: https://www.olx.in
utils/xpath_util.py:91: FutureWarning: Possible nested set at position 46
elif element.has_attr('value') and element['value'] != '' and bool(re.search(r'([\d]{1,}([/-]|\s|[.])?)+(\D+)?([/-]|\s|[.])?[[\d]{1,}',element['value']))== False and bool(re.search(r'\d{1,2}[:]\d{1,2}\s+((am|AM|pm|PM)?)',element['value']))==False:
Python says:'type'
Traceback (most recent call last):
File "utils/xpath_util.py", line 177, in <module>
if xpath_obj.generate_xpath(soup) is False:
File "utils/xpath_util.py", line 50, in generate_xpath
print ("%s_%s = %s"%(guessable_element, variable_name.encode('utf-8').decode('latin-1'), locator.encode('utf-8').decode('latin-1')))
AttributeError: 'NoneType' object has no attribute 'encode'
(venv3)
Rahul Bhave Qxf2@LAPTOP-S0A7MKF0 MINGW64 ~/code/rahul-qxf2/issue_215/qxf2-page-object-model (issue_239_xpath_util_exception)
$ python utils/xpath_util.py
Start of utils/xpath_util.py
Enter URL: http://sbhonline.com
Traceback (most recent call last):
File "utils/xpath_util.py", line 177, in <module>
if xpath_obj.generate_xpath(soup) is False:
File "utils/xpath_util.py", line 50, in generate_xpath
print ("%s_%s = %s"%(guessable_element, variable_name.encode('utf-8').decode('latin-1'), locator.encode('utf-8').decode('latin-1')))
File "C:\Program Files\Python38\lib\encodings\cp1252.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\x80' in position 16: character maps to <undefined>
we have the following safety catch in our code for the unknown guessable_element such as div, a, span, etc however this seems to be not working properly for the above 3 cases.m( Note that I checked these websites and div, span, a are the available guessable elements there)
safety catch code snippet:
elif not guessable_element in self.guessable_elements:
print("We are not supporting this guessable element")
III. Following 3 sites are giving
Unicode error and attribute error
we have the following safety catch in our code for the unknown guessable_element such as div, a, span, etc however this seems to be not working properly for the above 3 cases.m( Note that I checked these websites and div, span, a are the available guessable elements there)
safety catch code snippet: