Failed to find an element in selenium python - python-2.7

I using selenium in python2. And I want to find an element using (driver.find_elements_by_class_name())
but, no result from that code. but, if I try to find elements using (driver.find_element_by_class_name()), I get error message.
this is some my code:
def test():
driver.get('https://mbasic.facebook.com/aldhy.tompo')
button_lainnya = driver.find_element_by_link_text('Lainnya')
Class = button_lainnya.get_attribute('class')
print Class
all_button = driver.find_elements_by_class_name(Class)
print all_button
test()
and the output is:
cr cs
[]
and if I modified the code in line 6 be
all_button = driver.find_element_by_class_name(Class)
I get error message:
Traceback (most recent call last):
File "c:/Users/LENOVO/OneDrive/Documents/project/python/Selenium/robot olshop.py", line 119, in <module>
test()
File "c:/Users/LENOVO/OneDrive/Documents/project/python/Selenium/robot olshop.py", line 114, in test
pesan = driver.find_element_by_class_name(element)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 564, in find_element_by_class_name
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 978, in find_element
'value': value})['value']
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: .cr cs
this is source of the website:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>ALdhy</title><meta name="referrer" content="origin-when-crossorigin" id="meta_referrer" /><style type="text/css">/*<![CDATA[*/.cz{background:#fff;}.db{background:#e9ebee;}.dj{position:relative;top:1px;}.b .dc{padding:0;}.b .w{padding:2px;}.b .dg{padding:4px;}.dz{color:#4b4f56;}.dv{color:#1d2129;}.du{font-size:14px;line-height:20px;}.dk{font-size:16px;line-height:20px;}.ba{font-weight:normal;}.da{font-weight:bold;}.b .df{border-collapse:collapse;margin:0;width:100%;}.b td.di{border:0;padding:6px 0 6px 6px;vertical-align:middle;}.b .df .dl{padding:6px 6px 6px 0;text-align:right;white-space:nowrap;}.b .dh{padding:6px;}.b .m{border:0;border-collapse:collapse;margin:0;padding:0;width:100%;}.b .m tbody{vertical-align:top;}.b .em>tr>td,.b .em>tbody>tr>td,.b .m td.em{vertical-align:middle;}.b .m td{padding:0;}.b .m td.w{padding:2px;}.b .m td.dg{padding:4px;}.b .t{width:100%;}.b .dp{padding:4px;}.dm>*,.dm.dm>*{border-bottom:1px solid #e5e5e5;}.dm>:last-child{border-bottom:none;}.dm+.dm{border-top:1px solid #e5e5e5;}.ec{float:right;max-width:85%;overflow:hidden;text-align:right;text-overflow:ellipsis;}.ea{-moz-user-select:none;}.dy{width:100%;}.dy .eb{text-align:right;}.bj .bl .ce{color:#42464d;font-size:19px;font-weight:bold;}.bj.b .bl .ce{margin-left:0;position:static;}.bj.b .bl .cg{margin-left:5px;vertical-align:baseline;}.bj .bl .ct{padding-left:4px;}.ed{position:relative;}.b .bs{height:100%;overflow:hidden;position:absolute;}.b .bm{background-color:#1c1e21;height:100px;position:relative;}.b .bt{height:auto;}.b .bu{width:inherit;}.b .br{width:100%;}.b .bw{margin-top:-45px;}.cv{word-wrap:break-word;}.ca{position:relative;}.cb{border:2px solid #fff;box-shadow:0 1px 2px rgba(0, 0, 0, .1);display:inline-block;}.b .cd{padding:5px 0 5px 0;text-align:center;}.b .bz{text-align:center;}.bx{background-color:#fff;}.i{background-color:#3b5998;}.cx{background-color:#d8dfea;border-top:solid 1px #3b5998;}.j{padding:2px 3px;}.ee{padding:4px 3px;}.by{padding:6px 3px;}.b a,.b a:visited{color:#3b5998;text-decoration:none;}.b .cu,.b .cu:visited{color:#6d84b4;}.b .bg,.b .bg:visited{color:#fff;}.b a:focus,.b a:hover,.b .cu:focus,.b .cu:hover{background-color:#3b5998;color:#fff;}.b .bg:focus,.b .bg:hover{background-color:#fff;color:#3b5998;}.ci{color:gray;}.ch{font-size:small;}body,tr,input,textarea,.f{font-size:medium;}.dt{padding-left:4px;}.cj .cl{display:inline-block;margin-right:4px;}.b .cj .cl{float:left;}.b .cj .cm{display:table-cell;}.s{border:0;display:inline-block;vertical-align:top;}i.s u{position:absolute;width:0;height:0;overflow:hidden;}.dw{margin-right:4px;}.co{clear:both;}.dr{border-radius:50%;}.cc{background:#eceff5;}.cf{margin:2px 0 0 5px;}.cq .cr{display:block;}.cr{border:solid 2px;cursor:pointer;margin:0;padding:2px 6px 3px;text-align:center;}.cs,.b a.cs{background:#f3f4f5;border-color:#ccc #aaa #999;color:#505c77;}.i .cs,.b .i a.cs{background:#3b5998;border-color:#8a9ac5 #29447E #1a356e;color:#fff;}.cr .s{pointer-events:none;}.cr{display:inline-block;}.cr+.cr{margin-left:3px;}.cr input{background:none;border:none;margin:0;padding:0;}.cs input{color:#505c77;}.i .cs input{color:#fff;}.bv{background:#f2f2f2;}.bp:hover .bv{background:none;}body{text-align:left;direction:ltr;}body,tr,input,textarea,button{font-family:sans-serif;}body,p,figure,h1,h2,h3,h4,h5,h6,ul,ol,li,dl,dd,dt{margin:0;padding:0;}h1,h2,h3,h4,h5,h6{font-size:1em;font-weight:bold;}ul,ol{list-style:none;}article,aside,figcaption,figure,footer,header,nav,section{display:block;}.e #viewport{margin:0 auto;max-width:600px;}#page{position:relative;}.r,.r.s{display:block;}.o{display:block;}.p{height:20px;width:20px;}.k{background:#3b5998;padding:0 4px 4px;height:22px;}.k.k .x{background:#fff;border:1px solid #243872;box-sizing:border-box;font-size:small;height:22px;margin:0;width:100%;}.l.k{padding:1px 1px 3px;}.k .q{padding:1px 3px 0 0;}.k.k.k .bc{background:#627aba;border:1px solid #2e417e;color:#fff;font-size:x-small;font-weight:normal;height:22px;line-height:20px;margin-left:3px;}form{margin:0;border:0;}.v{border:0;display:block;margin:0;padding:0;}.bb{-moz-appearance:none;background:none;display:inline-block;font-size:12px;height:28px;line-height:28px;margin:0;overflow:visible;padding:0 9px;text-align:center;vertical-align:top;white-space:nowrap;}.b .bb{border-radius:2px;}.bd,a.bd,html .b a.bd{color:#fff;}.b .bd{background-color:#4267b2;border:1px solid #365899;}.b a.bd:hover,.b .bd:hover{background-color:#465e91;}.bd[disabled]{color:#899bc1;}.b .bd[disabled]:hover{background-color:#4267b2;}.b a.bb::after{content:"";display:inline-block;height:100%;vertical-align:middle;}.b .bb{padding:0 8px;}.b a.bb{height:26px;line-height:26px;}.ef{font-size:small;padding:7px 8px 8px;}.ew{border:1px solid;border-color:#8d949e;border-radius:4px;display:block;margin-top:8px;padding:4px;text-align:center;}.eu{display:block;font-size:x-small;margin:-3px -3px 1px -3px;padding:3px;}.b .ef td.et{padding-right:4px;}.b .ef td.ev{padding-left:4px;}.ef.eg{background-color:#444950;}.eg{border-top:1px solid #444950;color:#bec3c9;}.b .eg a,.b .eg a:visited{color:#bec3c9;}.b .eg a:focus,.b .eg a:hover{background:#dadde1;color:#1d2129;}.ei{margin-bottom:8px;}.ef.eg .ei>table{background:#d3d7dc;border:1px solid #444950;}.ep{background:#d3d7dc;}.eh .es{height:24px;line-height:24px;margin-left:2px;}.ek{background:#fff;}.eh .eq{background-color:transparent;color:#4b4f56;display:block;padding:0;width:100%;}.el .s{display:block;}.eh .ej .er{padding:2px;}.eh .ej .el{padding:4px;}.b .eh .ej{border:1px solid #8d949e;}.be{padding-bottom:1px;}.bf{display:inline-block;font-size:small;padding:2px 4px 2px;}.bh{color:#fff496;}.b a:hover .bh,.b a:focus .bh,.bf:hover .bh,.bf:focus .bh{color:#365899;}/*]]>*/</style><link rel="manifest" href="/data/manifest/" crossorigin="use-credentials" /></head><body tabindex="0" class="b c d e"><div class="f"><div id="viewport"><div class="g h" id="MChromeHeader"><div class="i j" role="banner" id="header"><form method="get" action="/search/" class="k l"><input type="hidden" name="search" value="Search" /><input type="hidden" name="search_source" value="top_nav" /><table class="m" role="presentation"><tbody><tr><td class="n"><a class="o p q" href="/home.php?ref_component=mbasic_home_logo&ref_page=%2Fwap%2Fprofile_timeline.php%3Ainfo"><img src="https://static.xx.fbcdn.net/rsrc.php/v3/ym/r/Gjhrhb7r0lb.png" width="20" height="20" class="r s" alt="Facebook logo" /></a></td><td class="t u"><input class="v w x" name="query" placeholder="Cari Facebook" autocomplete="off" autocorrect="off" spellcheck="false" type="text" /></td><td class="n y"><input value="Cari" type="submit" class="z ba bb bc bd" /></td></tr></tbody></table></form><div role="navigation" class="be">BerandaProfil<a accesskey="4" href="/messages/?ref_component=mbasic_home_header&ref_page=%2Fwap%2Fprofile_timeline.php%3Ainfo" class="bf bg"><strong class="bh">Pesan<span aria-label="6 belum dibaca">(6)</span></strong></a><a accesskey="3" href="/notifications.php?ref_component=mbasic_home_header&ref_page=%2Fwap%2Fprofile_timeline.php%3Ainfo" class="bf bg"><strong class="bh">Notifikasi<span aria-label="4 baru">(4)</span></strong></a><a accesskey="6" href="/buddylist.php?ref_component=mbasic_home_header&ref_page=%2Fwap%2Fprofile_timeline.php%3Ainfo" class="bf bg">Obrolan<span aria-label="194 tersedia">(194)</span></a><a accesskey="2" href="/friends/center/mbasic/?fb_ref=tn&sr=1&ref_component=mbasic_home_header&ref_page=%2Fwap%2Fprofile_timeline.php%3Ainfo" class="bf bg">Teman<span aria-label="971 permintaan baru">(971)</span></a><strong class="bh">Halaman<span aria-label="8 pemberitahuan baru">(8)</span></strong><strong class="bh">Grup(39)</strong><div class="bf" style="display:block;height:0;overflow:hidden;position:absolute;width:0;padding:0"> </div><a accesskey="5" href="/menu/bookmarks/?ref_component=mbasic_home_header&ref_page=%2Fwap%2Fprofile_timeline.php%3Ainfo" class="bf bg">Menu</a></div></div></div><div id="objects_container"><div class="bi" id="root" role="main"><div class="bj bk"><div class="bl"><div><div class="bm bn"><div class="bo" id="profile_cover_photo_container"><img src="https://scontent.fcgk24-1.fna.fbcdn.net/v/t1.0-9/cp0/e15/q65/c0.423.480.160a/26815493_327420491088444_1281706991021315294_n.jpg?_nc_cat=105&efg=eyJpIjoiYiJ9&_nc_oc=AQkhUONjtbuCFItR6Lk3h_7hcd--7T1jMINkeYWyvzWLIST129G7yx5jfheQSmUWgHI&_nc_ht=scontent.fcgk24-1.fna&oh=429c5f77922a1e93371c495cf5f1c50c&oe=5E5580F2" width="320" height="160" class="bt bu bv s" /></div></div></div><div class="bw bx by"><div><div class="bz"><div class="ca cb"><img src="https://scontent.fcgk24-1.fna.fbcdn.net/v/t1.0-1/cp0/e15/q65/c12.0.74.74a/p74x74/75398266_697134660783690_3381090451179175936_o.jpg?_nc_cat=108&efg=eyJpIjoiYiJ9&_nc_oc=AQld6oI7W4qR3K81zygg6KwiL5nJZ6y9jfi6rXSIsxp7HS88TiAUeSdI74KcjIKilhw&_nc_ht=scontent.fcgk24-1.fna&oh=386b6fde17bfcd7fbaaf5308b54e7f89&oe=5E4AF13B" class="cc s" alt="ALdhy" /></div></div><span><div class="cd"><span><strong class="ce">ALdhy <span class="alternate_name">(Tompo)</span></strong><img src="https://static.xx.fbcdn.net/rsrc.php/v3/yK/r/Ye1TQi63ARL.png" width="8" height="12" class="cf cg s" aria-label="ALdhy dapat dihubungi melalui teleponnya" /></span></div><span class="ch ci"><span><div class="cj ck" role="heading" id="u_0_1"><img src="https://static.xx.fbcdn.net/rsrc.php/v3/yS/r/1HRQT0OcHKI.png" width="12" height="14" class="cl s" role="presentation" aria-level="4" /><span class="cm ch">Bekerja di <a class="cn" href="/profile.php?id=107980922563405">Swasta</a></span><div class="co"></div></div></span></span></span></div></div><div class="cp"><table class="cq"><tr><td>Tambah Jadi Teman</td><td>Pesan</td><td>Lainnya</td></tr></table></div><div class="ct f ci">Linimasa · Teman · Foto · Suka</div></div><div class="cv"><div class="cw bx"><h3 class="cx j">Teman</h3></div><div><div class="bx">Lihat Semua Teman (1040)</div></div></div><div class="cy"><div id="work"><div class="cz"><div class="da db dc dd de"><table class="df dg"><tr><td class="t dh di" aria-hidden="false"><div class="dj" role="heading" tabindex="0"><span class="dk">Pekerjaan</span></div></td><td class="t dl di"><div></div></td></tr></table></div><div class="dm dn"><div class="do dp" id="u_0_0"><div class="cj dq"><a class="cl" href="/profile.php?id=107980922563405"><img src="https://scontent.fcgk24-1.fna.fbcdn.net/v/t1.0-1/cp0/e15/q65/c14.0.48.48a/p48x48/399548_10149999285987789_1102888142_n.png.jpg?_nc_cat=1&efg=eyJpIjoiYiJ9&_nc_oc=AQl8gYxpUBwBm01VIUkCjywHWgrHloJpYkVJY8bXRaDXHJWwKfRiC-GVvrpLBOvO3tU&_nc_ht=scontent.fcgk24-1.fna&oh=d390e65f185dc2fae2c2bbec1e845648&oe=5E60DEE1" class="dr ds cc s" alt="Swasta" /></a><div class="dt cm"><div><span class="du dv da dw"><a class="cn" href="/profile.php?id=107980922563405">Swasta</a></span></div></div><div class="co"></div></div></div></div></div></div></div><div id="contact-info"><div class="cz"><div class="da db dc dd de"><table class="df dg"><tr><td class="t dh di" aria-hidden="false"><div class="dj" role="heading" tabindex="0"><span class="dk">Info Kontak</span></div></td><td class="t dl di"><div></div></td></tr></table></div><div class="dm dn"><div class="do dp dx" title="Facebook"><table cellspacing="0" cellpadding="0" class="dy"><tr><td valign="top"><div class="dz ea"><span class="dk dz ba">Facebook</span></div></td><td valign="top" class="eb"><div class="ec"> /aldhy.tompo</div></td></tr></table></div></div></div></div><div id="basic-info"><div class="cz"><div class="da db dc dd de"><table class="df dg"><tr><td class="t dh di" aria-hidden="false"><div class="dj" role="heading" tabindex="0"><span class="dk">Info Umum</span></div></td><td class="t dl di"><div></div></td></tr></table></div><div class="dm dn"><div class="do dp dx" title="Jenis Kelamin"><table cellspacing="0" cellpadding="0" class="dy"><tr><td valign="top"><div class="dz ea"><span class="dk dz ba">Jenis Kelamin</span></div></td><td valign="top" class="eb"><div class="ec">Laki-laki</div></td></tr></table></div></div></div></div><div id="nicknames"><div class="cz"><div class="da db dc dd de"><table class="df dg"><tr><td class="t dh di" aria-hidden="false"><div class="dj" role="heading" tabindex="0"><span class="dk">Nama Lain</span></div></td><td class="t dl di"><div></div></td></tr></table></div><div class="dm dn"><div class="do dp dx" title="Nama panggilan"><table cellspacing="0" cellpadding="0" class="dy"><tr><td valign="top"><div class="dz ea"><span class="dk dz ba">Nama panggilan</span></div></td><td valign="top" class="eb"><div class="ec">Tompo</div></td></tr></table></div></div></div></div><div id="relationship"><div class="cz"><div class="da db dc dd de"><table class="df dg"><tr><td class="t dh di" aria-hidden="false"><div class="dj" role="heading" tabindex="0"><span class="dk">Hubungan</span></div></td><td class="t dl di"><div></div></td></tr></table></div><div class="dm dn"><div class="ed dp"></div></div></div></div><div id="year-overviews"><div class="cz"><div class="da db dc dd de"><table class="df dg"><tr><td class="t dh di" aria-hidden="false"><div class="dj" role="heading" tabindex="0"><span class="dk">Peristiwa Penting</span></div></td><td class="t dl di"><div></div></td></tr></table></div><div class="dm dn"><div class="dp"><div></div><div></div><div></div><div></div><div></div></div></div></div></div><a name="footer-actions-basic"><div class="bx ee">Blokir orang ini<br />Cari Dukungan atau Laporkan Profil</div></a></div><div style="display:none"></div></div></div><div class="cz"><div class="ef eg"><div id="search_div"><form method="get" action="/search/"><input type="hidden" name="search" /><input type="hidden" name="search_source" value="footer" /><div class="eh ei"><table class="m ej ek" role="presentation"><tbody><tr><td class="n el em"><label for="u_0_3"><img src="https://static.xx.fbcdn.net/rsrc.php/v3/yC/r/hwCZEAcHQnm.png" width="20" height="20" class="en s" role="presentation" /></label></td><td class="t eo em"><input class="v dc ep eq" aria-label="Cari" name="query" id="u_0_3" type="text" /></td><td class="n er em"><input value="Cari" type="submit" class="z ba bb es bd" /></td></tr></tbody></table></div></form></div><table class="m" role="presentation"><tbody><tr><td class="t et" style="width:50%"><a class="eu" href="/pages/?ref=Footer&ref_component=mbasic_footer&ref_page=%2Fwap%2Fprofile_timeline.php%3Ainfo">Halaman Anda</a><a accesskey="0" class="eu" href="/help/?ref_component=mbasic_footer&ref_page=%2Fwap%2Fprofile_timeline.php%3Ainfo">Bantuan</a><a accesskey="7" class="eu" href="/settings/?entry_point=mbasic_footer_link&ref_component=mbasic_footer&ref_page=%2Fwap%2Fprofile_timeline.php%3Ainfo">Pengaturan & Privasi</a></td><td class="t ev" style="width:50%"><a class="eu" href="/bugnub/?source=Footer&ref_component=mbasic_footer&ref_page=%2Fwap%2Fprofile_timeline.php%3Ainfo">Laporkan Masalah</a><a accesskey="8" class="eu" href="/policies/?ref_component=mbasic_footer&ref_page=%2Fwap%2Fprofile_timeline.php%3Ainfo">Ketentuan & Kebijakan</a><a class="eu" href="/logout.php?h=AfdzPVB07vM3sCQL&t=1573644042&button_name=logout&button_location=footer&source=mbasic_logout_button&ref_component=mbasic_footer&ref_page=%2Fwap%2Fprofile_timeline.php%3Ainfo" id="mbasic_logout_button">Keluar (Fatonah)</a></td></tr></tbody></table><a class="ew" href="#header">Kembali ke Atas</a></div></div></div></div></body></html>
so, anyone can help me to fix this problem? how to find all elements in class 'cr cs'?
and how to fix the problem, if I just want to find an element in class 'cr cs'?

The call to button_lainnya.get_attribute('class') returns the class list for that element, which has two classes separated by a space character.
The call to get_element_by_class_name(Class) expects be to given a single class name --- "cr" or "cs", but not both.
If you need to find the element using both class names, then you need to use a CSS selector:
driver.find_element_by_css_selector(".cr.cs")
My python is a little rusty, but this should work:
selector = "." + Class.replace(" ", ".")
driver.find_element_by_css_selector(selector)

Why you are getting this error? Because your script doesn't find Lainnya in full page I also try and I get the same error when I see in the page there is not Lainnya text
SOLUTION:
Change The text you want for example ALdhy
or something because when I visit this page I see there is ALdhy and other name not Lainnya name so that's why u get this error
The error is showing up correctly, because it can't find Lainnya in your page

Related

How to make the specified nodes horizontally aligned in Mermaid?

This is my flowchart:
graph TB
aaa ---> bbb ---> ddd & ccc
ddd -.-> fff
ccc --->|eee| fff
fff ---> hhh & ggg & kkk
hhh --->|iii| mmm
ggg & kkk -.-> mmm
But actually I want the node ccc and node ddd to be aligned horizontally. And the hhh , node ggg and kkk to be aligned horizontally. Is it possible?
Of course, the purpose of this post is to think about how to align these nodes horizontally, but if possible I would also like to make these edges as short as possible to save space while aligning them. For example, I want the node ddd to go up, not the node ccc to come down
You can achieve this by using longer or shorter arrows, which changes the minimum link length between nodes:
graph TB
aaa ---> bbb ---> ddd & ccc
ddd -..-> fff
%% ^^ extra .
ccc --->|eee| fff
fff ---> hhh & ggg & kkk
hhh --->|iii| mmm
ggg & kkk -..-> mmm
%% ^^ extra .
According Minimum length of a link permalink
Each node in the flowchart is ultimately assigned to a rank in the rendered graph, i.e. to a vertical or horizontal level (depending on the flowchart orientation), based on the nodes to which it is linked. By default, links can span any number of ranks, but you can ask for any link to be longer than the others by adding "extra dashes" in the link definition.
so you don't need to triple dash
change
C2 ---> |msg| D to C2 --> |msg| D
E1 --->|msg| F to E1 -->|msg| F
Compare
<script src="https://cdnjs.cloudflare.com/ajax/libs/mermaid/8.14.0/mermaid.min.js"></script>
<table>
<tr>
<th>Bad</th>
<th>Good</th>
</tr>
<tr>
<td>
<div class="mermaid">
graph TB
A --> B --> C1 & C2
C1 -.-> D
C2 ---> |msg| D
D --> E1 & E2 & E3
E1 --->|msg| F
E2 & E3 -.-> F
</div>
</td>
<td>
<div class="mermaid">
graph TB
A --> B --> C1 & C2
C1 -.-> D
C2 --> |msg| D
D --> E1 & E2 & E3
E1 -->|msg| F
E2 & E3 -.-> F
</div>
</td>
</tr>
</table>

Unexpected identifier Jest Vue SVG

I've had this error during running jest on my Vue. I run jest command, and get the error below.
If I remove the svg element in the component. It's working fine
Error message
FAIL test/Header.spec.js
● Test suite failed to run
/Users/jakzaizzat/Code/taiger/kwa/kcp-admin-ui/node_modules/#babel/runtime-corejs2/helpers/esm/defineProperty.js:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import _Object$defineProperty from "../../core-js/object/define-property";
^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Unexpected identifier
19 | />
20 | <path
> 21 | d="M15.9999 0L0 8.5541V8.77758V27.0448L16.0001 35.5984L32 27.045V8.5541L15.9999 0ZM16.4239 25.007L18.6367 26.3025L21.1325 24.9877L21.5461 25.7729L18.614 27.3176L15.9848 25.7781L13.3554 27.3176L10.4233 25.7729L10.8369 24.9877L13.3325 26.3025L15.5364 25.0122L15.5358 22.9129L10.7279 19.9154V16.1301L4.71654 13.6018L5.06044 12.7836L11.6154 15.5405V19.1554H20.353V15.5405L26.908 12.7836L27.2519 13.6018L21.2407 16.1301V19.9155L16.4231 22.9197L16.4239 25.007Z"
| ^
22 | fill="white"
23 | />
24 | </svg>
Header.spec.js
import Header from "../src/components/shared/Card.vue";
import {mount} from "#vue/test-utils";
describe('Header.vue', () => {
test('render header navigation', () => {
const wrapper = mount(Header);
expect(wrapper.isVueInstance()).toBeTruthy()
});
});
Header.vue
<div class="px-4">
<router-link
to="/"
class="logo"
>
<svg
width="32"
height="36"
viewBox="0 0 32 36"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M15.9849 22.1472L19.3588 20.043H12.6101L15.9849 22.1472Z"
fill="white"
/>
<path
d="M15.9999 0L0 8.5541V8.77758V27.0448L16.0001 35.5984L32 27.045V8.5541L15.9999 0ZM16.4239 25.007L18.6367 26.3025L21.1325 24.9877L21.5461 25.7729L18.614 27.3176L15.9848 25.7781L13.3554 27.3176L10.4233 25.7729L10.8369 24.9877L13.3325 26.3025L15.5364 25.0122L15.5358 22.9129L10.7279 19.9154V16.1301L4.71654 13.6018L5.06044 12.7836L11.6154 15.5405V19.1554H20.353V15.5405L26.908 12.7836L27.2519 13.6018L21.2407 16.1301V19.9155L16.4231 22.9197L16.4239 25.007Z"
fill="white"
/>
</svg>
</router-link>
</div>
Any idea what is the cause of this issue?

Grouping by result of sum

I'm converting tables for a client and some elements need to span across multiple columns. Each element has the attribute aid:ccols which indicates across how many columns this value should span. I'm trying to group these elements until the sum of aid:ccols equals basictable/#aid:tcols and so on.
I tried multiple things by using xsl:for-each, group-by but nothing seems to work.
<basictable xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/" aid:table="table" aid:trows="7" aid:tcols="3">
<cell-tab-tit-center aid:table="cell" aid:crows="1" aid:ccols="3">1. Les « salaires » du mois</cell-tab-tit-center>
<cell-tab-txt-left aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="67.53149606308261">Salaire mensuel</cell-tab-txt-left>
<cell-tab-txt-left aid:table="cell" aid:crows="1" aid:ccols="2">Arrêté à la date de rupture du contrat (fin du préavis, même en cas de dispense par l’employeur).</cell-tab-txt-left>
<cell-tab-txt-left aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="67.53149606308261">Rappels éventuels</cell-tab-txt-left>
<cell-tab-txt-left aid:table="cell" aid:crows="1" aid:ccols="2">Vérifier si des rappels restent dus.</cell-tab-txt-left>
<cell-tab-txt-left aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="67.53149606308261">Primes annuelles</cell-tab-txt-left>
<cell-tab-txt-left aid:table="cell" aid:crows="1" aid:ccols="2">Vérifier si les primes annuelles sont dues au prorata.</cell-tab-txt-left>
<cell-tab-txt-left aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="67.53149606308261">Ind. comp. cp N-1</cell-tab-txt-left>
<cell-tab-txt-left aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="147.40157480314957">Contrôler le solde de cp.</cell-tab-txt-left>
<cell-tab-txt-left aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="248.94881889754743">
comparaison maintien/10<superscript>e</superscript>
rém. de la période de réf. N-1.
</cell-tab-txt-left>
<cell-tab-txt-left aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="67.53149606308261">Ind. comp. cp en cours</cell-tab-txt-left>
<cell-tab-txt-left aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="147.40157480314957">Calculer le droit, au réel + règle des équivalences, jusqu’à la fin du préavis.</cell-tab-txt-left>
<cell-tab-txt-left aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="248.94881889754743">
comparaison maintien/10<superscript>e</superscript>
rém. de la période en cours et jusqu’à la fin du préavis.
</cell-tab-txt-left>
<cell-tab-subtit-left aid:table="cell" aid:crows="1" aid:ccols="3">
<b>Permet d’obtenir le total du mois représentant du salaire</b>
</cell-tab-subtit-left>
</basictable>
The result should be
<table>
<tr>
<th colspan="3">1. Les « salaires » du mois</th>
</tr>
<tr>
<td>Salaire mensuel</td>
<td>Arrêté à la date de rupture du contrat (fin du préavis, même en cas de dispense par l’employeur).</td>
</tr>
<tr>
<td>Rappels éventuels</td>
<td>Vérifier si des rappels restent dus.</td>
</tr>
<tr>
<td>Primes annuelles</td>
<td>Vérifier si les primes annuelles sont dues au prorata.</td>
</tr>
<tr>
<td>Ind. comp. cp N-1</td>
<td>Contrôler le solde de cp.</td>
<td>
comparaison maintien/10
<superscript xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/">e</superscript>
rém. de la période de réf. N-1.
</td>
</tr>
<tr>
<td>Ind. comp. cp en cours</td>
<td>Calculer le droit, au réel + règle des équivalences, jusqu’à la fin du préavis.</td>
<td>
comparaison maintien/10
<superscript xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/">e</superscript>
rém. de la période en cours et jusqu’à la fin du préavis.
</td>
</tr>
.
.
.
</table>
My code:
<xsl:template match="cell-tab-txt-right | cell-tab-subtit-left | cell-tab-txt-center | cell-tab-txt-left | cell-tab-subtit-right | cell-tab-subtit-center | cell-tab-tit-center | cell-tab-tit-right | cell-tab-tit-left">
<xsl:param name="columns" tunnel="yes"/>
<xsl:if test="$columns != 0">
<xsl:choose>
<xsl:when test="#aid:ccols = $columns">
<xsl:element name="tr">
<xsl:element name="th">
<xsl:attribute name="colspan"><xsl:value-of select="#aid:ccols"></xsl:value-of></xsl:attribute>
<xsl:apply-templates/>
</xsl:element>
</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:element name="tr">
<xsl:apply-templates select=".|following-sibling::*[1][position() + (#aid:ccols - 1) $lt; $columns]" mode="list"/>
</xsl:element>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:template>
At https://xsltfiddle.liberty-development.net/bFN1yaa/2 I have tried to convert the xsl:iterate example from the comment to sibling recursion:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"
exclude-result-prefixes="#all"
version="2.0">
<xsl:output method="html" indent="yes" version="5"/>
<xsl:template match="#* | node()">
<xsl:copy>
<xsl:apply-templates select="#* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="basictable">
<table>
<xsl:variable name="max-cols" select="xs:integer(#aid:tcols)"/>
<xsl:apply-templates select="*[1]" mode="row">
<xsl:with-param name="max-cols" select="$max-cols"/>
</xsl:apply-templates>
</table>
</xsl:template>
<xsl:template match="basictable/*" mode="row">
<xsl:param name="max-cols"/>
<xsl:param name="cells" select="()"/>
<xsl:variable name="current-cells" select="$cells, ."/>
<xsl:variable name="sum-cells" select="sum($current-cells/#aid:ccols)"/>
<xsl:if test="$sum-cells eq $max-cols">
<tr>
<xsl:apply-templates select="$current-cells"/>
</tr>
</xsl:if>
<xsl:apply-templates select="following-sibling::*[1]" mode="row">
<xsl:with-param name="cells" select="if ($sum-cells eq $max-cols) then () else $current-cells"/>
<xsl:with-param name="max-cols" select="$max-cols"/>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="basictable/*">
<td>
<xsl:apply-templates/>
</td>
</xsl:template>
</xsl:stylesheet>
I think the grouping of the children of basictable into tr works the same as the xsl:iterate sample, in both samples I have not tried to implement the use of colspan and th cells as I am not sure what determines that.

Not able to format dataframe using xtable

I have a dataframe and I want to display that into a R markdown HTML file. I am able to generate a table using Kable function of Knitr, but I wanted to change look and feel, like highlighting the header. as some suggested on Stackoverflow to use xtable, I tried to do that. I took reference from Stackoverflow and try to design my outlike like this.
large <- function(x){
paste0('{\\Large{\\bfseries ', x, '}}')
}
italic <- function(x){
paste0('{\\emph{ ', x, '}}')
}
dat <- Final_Summary_table[1:3, 1:6]
print(xtable(dat),
sanitize.rownames.function = italic,
sanitize.colnames.function = large,
booktabs = TRUE,
floating = TRUE)
But instead of getting a beautiful table, what I am getting is something like we writee on a notepad.
% latex table generated in R 3.3.1 by xtable 1.8-2 package % Mon Nov 14 09:33:01 2016 \begin{table}[ht] \centering \begin{tabular}{rllrrrl} \toprule & {\Large{\bfseries ODS_Tables}} & {\Large{\bfseries AppDS_Tables}} & {\Large{\bfseries ODS_Total_Records}} & {\Large{\bfseries AppDS_Total_Records}} & {\Large{\bfseries Change_in_Count}} & {\Large{\bfseries Results}} \\ \midrule {\emph{ 1}} & HCC & tRefHCCCodes & 338.00 & 338.00 & 0.00 & PASS \\ {\emph{ 2}} & HCC\_COEFF & tRefHHCCOEFFs & 1166.00 & 794.00 & 372.00 & FAIL \\ {\emph{ 3}} & HCC\_HIERARCHY & tRefHHCHierarchies & 337.00 & 253.00 & 84.00 & FAIL \\ \bottomrule \end{tabular} \end{table}
any clue or help please.
I used follwing CSS formatting and it solved the issue.
<STYLE TYPE="text/css">
<!--
table {
width:100%;
}
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
th, td {
padding: 5px;
text-align: left;
}
table tr:nth-child(even) {
background-color: #eee;
}
table tr:nth-child(odd) {
background-color:#fff;
}
table th {
background-color: black;
color: white;
}
--->
</STYLE>

Filtering using xslt for specific node values

I need to filter huge and redundant xml file.
Easy thing is to eliminate all nodes with no attributes and no content:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="#*|node()">
<xsl:if test=". != '' or ./#* != ''">
<xsl:copy>
<xsl:apply-templates select="#*|node()"/>
</xsl:copy>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
but i also need to filter out nodes containing
<type>0</type>
nodes containing only
<whatever id="-1 />
and nodes containing only empty attributes like:
<dateacquired year="" month="" day="" long="" unformatted=""/>
an excerpt of my (machine generated) input file is:
<record table="book" id="1">
<bookdata>
<bookid unformatted="1">1</bookid>
<marked bool="False">No</marked>
<lastmodified year="2013" month="09" day="25" long="Wednesday, September 25, 2013" unformatted="20130925">09/25/2013</lastmodified>
<title>Intervista Col Vampiro</title>
<fulltitle>Ciclo Dei Vampiri: Intervista Col Vampiro</fulltitle>
<fulltitle2>Intervista Col Vampiro (Ciclo Dei Vampiri)</fulltitle2>
<referenceno>BB00001</referenceno>
<publishdate year="1993" month="" day="" long="1993" unformatted="1993">1993</publish date>
<copyrightdate year="" month="" day="" long="" unformatted=""/>
<type id="-1"/>
<authors sort="Rice, Anne">
<author id="1">
<name>Anne Rice</name>
<sortby>Rice, Anne</sortby>
<roles/>
</author>
</authors>
<credits/>
<image1>
<filename>Book_1_3.jpg</filename>
<type>2</type>
<notes/>
</image1>
<image2>
<filename/>
<type>0</type>
<notes/>
</image2>
<image3>
<filename/>
<type>0</type>
<notes/>
</image3>
<image4>
<filename/>
<type>0</type>
<notes/>
</image4>
<image5>
<filename/>
<type>0</type>
<notes/>
</image5>
<image6>
<filename/>
<type>0</type>
<notes/>
</image6>
<image7>
<filename/>
<type>0</type>
<notes/>
</image7>
<image8>
<filename/>
<type>0</type>
<notes/>
</image8>
<image9>
<filename/>
<type>0</type>
<notes/>
</image9>
<subtitle/>
<titlesort>Intervista Col Vampiro</titlesort>
<publisher id="1">Salani</publisher>
<publicationplace id="-1"/>
<isbn/>
<lccn/>
<lccallnum/>
<dewey>823.9</dewey>
<country id="-1"/>
<pages unformatted="283">283</pages>
<numberofsections unformatted="0">0</numberofsections>
<printedby id="-1"/>
<binding id="-1"/>
<edition id="1">Ebook</edition>
<printing id="-1"/>
<language id="-1"/>
<series id="1">Ciclo Dei Vampiri</series>
<releaseno unformatted="0">0</releaseno>
<originaltitle>Interview With The Vampire</originaltitle>
<originalsubtitle/>
<originalpublisher id="-1"/>
<originalcountry id="-1"/>
<originallanguage id="-1"/>
<originalcopyright year="1976" month="" day="" long="1976" unformatted="1976">1976</originalcopyright>
<price integer="8" fraction="0" unformatted="8.0">8.00</price>
<value integer="0" fraction="0" unformatted="0.0">0.00</value>
<sellingprice integer="0" fraction="0" unformatted="0.0">0.00</sellingprice>
<changeinvalue>0.00</changeinvalue>
<changeinvaluepr>0.00</changeinvaluepr>
<condition id="-1"/>
<appraiser id="-1"/>
<insurance id="-1"/>
<registered year="2005" month="09" day="10" long="Saturday, September 10, 2005" unformatted="20050910">09/10/2005</registered>
<status id="-1"/>
<dateacquired year="" month="" day="" long="" unformatted=""/>
<acquiredfrom id="-1"/>
<personalrating id="-1"/>
<category id="1">Horror-Gotico</category>
<subcategory id="-1"/>
<owner id="-1"/>
<location id="-1"/>
<keywords>
<keyword id="1">Vampiro</keyword>
<keyword id="2">Vampiri</keyword>
</keywords>
<newbook bool="False">No</newbook>
<onloan bool="False">No</onloan>
<overdue bool="False">No</overdue>
<borrower id="-1"/>
<borrowercategory id="-1"/>
<dateborrowed year="" month="" day="" long="" unformatted=""/>
<datedue year="" month="" day="" long="" unformatted=""/>
<reserved bool="False">No</reserved>
<reservedto id="-1"/>
<reserveddate year="" month="" day="" long="" unformatted=""/>
<awards/>
<awardyear/>
<awarddetails/>
<nominations/>
<nominationyear/>
<nominationdetails/>
<custom01/>
<custom02/>
<custom03>http://www.ddunlimited.net/viewtopic.php?f=1079&t=3749847</custom03>
<custom04/>
<custom05 id="-1"/>
<custom06 id="-1"/>
<custom07 id="-1"/>
<custom08 id="-1"/>
<custom09 year="" month="" day="" long="" unformatted=""/>
<custom10 integer="0" fraction="0" unformatted="0.0">0.00</custom10>
<custom11 bool="True">Yes</custom11>
<custom12 bool="False">No</custom12>
<custom13 bool="False">No</custom13>
<custom14 bool="True">Yes</custom14>
<custom15 bool="False">No</custom15>
<custom16 bool="False">No</custom16>
<custom17 bool="False">No</custom17>
<custom18 bool="False">No</custom18>
<notes>ed2k://|file|eBook.ITA.001.Anne.Rice.Intervista.Col.Vampiro.(doc.lit.pdf.rtf).[Hyps].rar|1998285|81D4C283C03E5787170A33C335577533|/</notes>
<synopsis>A San Francisco alle soglie del 2000 il giornalista Mallory viene avvicinato da Louis De Point Du Lac, vampiro dal 1791, quando era un proprietario terriero presso New Orleans. Ridotto alla disperazione per la perdita della moglie e della figlioletta vieneiniziato alla sua tenebrosa e ferina esistenza da Lestat, collega di origini parigine, che cerca invano di far superare al discepolo l&apos;innata repulsione per l&apos;omicidio. Invano Louis si ciba di sangue di ratti e galline, e fà fuggire i servi incendiando la casa. Ormai Lestat lo domina e lo coinvolge in efferate uccisioni di innocenti. Una bimba orfana, Claudia, viene "adottata" dai due e si rivela feroce quant&apos;altri mai.</synopsis>
<reviews/>
<weblinks/>
<weblinktype id="1"/>
<filelinks/>
<filelinktype id="1"/>
<barcode/>
<originalseries id="-1"/>
<originalreleaseno unformatted="0">0</originalreleaseno>
<readhistory/>
<lastread year="" month="" day="" long="" unformatted=""/>
<readcount unformatted="0">0</readcount>
<dustjacketcondition id="-1"/>
<dimensions_width integer="0" fraction="0" unformatted="0.0">0.00</dimensions_width>
<dimensions_height integer="0" fraction="0" unformatted="0.0">0.00</dimensions_height>
<dimensions_depth integer="0" fraction="0" unformatted="0.0">0.00</dimensions_depth>
<coverprice integer="0" fraction="0" unformatted="0.0">0.00</coverprice>
<coverprice_currency id="-1"/>
<booklinks/>
</bookdata>
<contentsdata items="0"/>
</record>
desired output would be:
<record table="book" id="1">
<bookdata>
<bookid unformatted="1">1</bookid>
<marked bool="False">No</marked>
<lastmodified year="2013" month="09" day="25" long="Wednesday, September 25, 2013" unformatted="20130925">09/25/2013</lastmodified>
<title>Intervista Col Vampiro</title>
<fulltitle>Ciclo Dei Vampiri: Intervista Col Vampiro</fulltitle>
<fulltitle2>Intervista Col Vampiro (Ciclo Dei Vampiri)</fulltitle2>
<referenceno>BB00001</referenceno>
<publishdate year="1993" month="" day="" long="1993" unformatted="1993">1993</publish date>
<authors sort="Rice, Anne">
<author id="1">
<name>Anne Rice</name>
<sortby>Rice, Anne</sortby>
</author>
</authors>
<image1>
<filename>Book_1_3.jpg</filename>
<type>2</type>
</image1>
<titlesort>Intervista Col Vampiro</titlesort>
<publisher id="1">Salani</publisher>
<dewey>823.9</dewey>
<pages unformatted="283">283</pages>
<numberofsections unformatted="0">0</numberofsections>
<edition id="1">Ebook</edition>
<series id="1">Ciclo Dei Vampiri</series>
<releaseno unformatted="0">0</releaseno>
<originaltitle>Interview With The Vampire</originaltitle>
<originalcopyright year="1976" month="" day="" long="1976" unformatted="1976">1976</originalcopyright>
<price integer="8" fraction="0" unformatted="8.0">8.00</price>
<value integer="0" fraction="0" unformatted="0.0">0.00</value>
<sellingprice integer="0" fraction="0" unformatted="0.0">0.00</sellingprice>
<changeinvalue>0.00</changeinvalue>
<changeinvaluepr>0.00</changeinvaluepr>
<registered year="2005" month="09" day="10" long="Saturday, September 10, 2005" unformatted="20050910">09/10/2005</registered>
<category id="1">Horror-Gotico</category>
<keywords>
<keyword id="1">Vampiro</keyword>
<keyword id="2">Vampiri</keyword>
</keywords>
<newbook bool="False">No</newbook>
<onloan bool="False">No</onloan>
<overdue bool="False">No</overdue>
<reserved bool="False">No</reserved>
<custom03>http://www.ddunlimited.net/viewtopic.php?f=1079&t=3749847</custom03>
<custom10 integer="0" fraction="0" unformatted="0.0">0.00</custom10>
<custom11 bool="True">Yes</custom11>
<custom12 bool="False">No</custom12>
<custom13 bool="False">No</custom13>
<custom14 bool="True">Yes</custom14>
<custom15 bool="False">No</custom15>
<custom16 bool="False">No</custom16>
<custom17 bool="False">No</custom17>
<custom18 bool="False">No</custom18>
<notes>ed2k://|file|eBook.ITA.001.Anne.Rice.Intervista.Col.Vampiro.(doc.lit.pdf.rtf).[Hyps].rar|1998285|81D4C283C03E5787170A33C335577533|/</notes>
<synopsis>A San Francisco alle soglie del 2000 il giornalista Mallory viene avvicinato da Louis De Point Du Lac, vampiro dal 1791, quando era un proprietario terriero presso New Orleans. Ridotto alla disperazione per la perdita della moglie e della figlioletta vieneiniziato alla sua tenebrosa e ferina esistenza da Lestat, collega di origini parigine, che cerca invano di far superare al discepolo l&apos;innata repulsione per l&apos;omicidio. Invano Louis si ciba di sangue di ratti e galline, e fà fuggire i servi incendiando la casa. Ormai Lestat lo domina e lo coinvolge in efferate uccisioni di innocenti. Una bimba orfana, Claudia, viene "adottata" dai due e si rivela feroce quant&apos;altri mai.</synopsis>
<weblinktype id="1"/>
<filelinktype id="1"/>
<originalreleaseno unformatted="0">0</originalreleaseno>
<readcount unformatted="0">0</readcount>
<dimensions_width integer="0" fraction="0" unformatted="0.0">0.00</dimensions_width>
<dimensions_height integer="0" fraction="0" unformatted="0.0">0.00</dimensions_height>
<dimensions_depth integer="0" fraction="0" unformatted="0.0">0.00</dimensions_depth>
<coverprice integer="0" fraction="0" unformatted="0.0">0.00</coverprice>
</bookdata>
<contentsdata items="0"/>
</record>
Problem is I do not really grok transformations and, while I tried to read about them, I didn't find a comprehensible tutorial. Any pointer welcome!
As an additional bonus I would also like to filter out specific "null" items like the above dimensions_*.
TiA
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="#*|node()">
<xsl:copy>
<xsl:apply-templates select="#*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="*[normalize-space(.) = 0]" />
<xsl:template match="*[normalize-space(.) = '' and count(#*[. = '']) = count(#*)]" />
<!-- write more empty templates for nodes that should be removed -->
</xsl:stylesheet>
Note that count(#*[. = '']) = count(#*) could be written as not(#*[. != '']) if you fancy that.