protractor how to select element by svg or ng-click - protractor

I'm trying to click this element:
<a ng-click="vm.showEditOpportunity(3122)" class="btn btn-sm">
<svg class="svg-inline--fa fa-pencil-alt fa-w-16" style="color: #4b286d;"
data-toggle="tooltip" title="Edit this Opportunity"
aria-labelledby="svg-inline--fa-title-381" data-prefix="fas" data-icon="pencil-alt"
role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" data-fa-i2svg="">
<title id="svg-inline--fa-title-381">Edit this Opportunity</title>
<path fill="currentColor" d="M497.9 142.1l-46.1 46.1c-4.7 4.7-12.3 4.7-17
0l-111-111c-4.7-4.7-4.7-12.3 0-17l46.1-46.1c18.7-18.7 49.1-18.7 67.9 0l60.1
60.1c18.8 18.7 18.8 49.1 0 67.9zM284.2 99.8L21.6 362.4.4 483.9c-2.9 16.4
11.4 30.6 27.8 27.8l121.5-21.3 262.6-262.6c4.7-4.7 4.7-12.3
0-17l-111-111c-4.8-4.7-12.4-4.7-17.1 0zM124.1 339.9c-5.5-5.5-5.5-14.3
0-19.8l154-154c5.5-5.5 14.3-5.5 19.8 0s5.5 14.3 0 19.8l-154 154c-5.5
5.5-14.3 5.5-19.8 0zM88 424h48v36.3l-64.5 11.3-31.1-31.1L51.7 376H88v48z
</path>
</svg>
</a>
I have tried the following but none works, with error "no element found using locator: XXXXXX". What is the proper way of clicking this element?
element(by.css('[ng-click="vm.showEditOpportunity(3122)"]')).click();
element(by.xpath("//a[contains(text(),'vm.showEditOpportunity(3122)')]")).click();
element(by.xpath("//svg[#title='Edit this Opportunity']")).click();

Had the same problem with elements with ng-click. Describing them through the ng-click is fine, but the only way it works for me is to wait for visibility of the element with ExpectedConditions.
var element = element(by.css('[ng-click="vm.showEditOpportunity(3122)"]'));
browser.ignoreSynchronization = true;
browser.wait(protractor.ExpectedConditions.visibilityOf(element),500);
element.click();

Related

how to pass data to a Tailwind modal using Laravel

i have this code in tailwind
#foreach($studenti as $student)
<a data-modal-toggle="defaultModal" data-target="#myModal{{$student->id }} href="#" class="hover:text-blue-700">{{$student->name}}</a>
and this is the Main modal
<!-- Main modal -->
<div id="myModal{{$student->id}}" tabindex="-1" aria-hidden="true" class="hidden overflow-y-auto overflow-x-hidden fixed top-0 right-0 left-0 z-50 w-full md:inset-0 h-modal md:h-full justify-center items-center">
<div class="relative p-4 w-full max-w-2xl h-full md:h-auto">
<!-- Modal content -->
<div class="relative bg-white rounded-lg shadow dark:bg-gray-700">
<!-- Modal header -->
<div class="flex justify-between items-start p-4 rounded-t border-b dark:border-gray-600">
<h3 class="text-xl font-semibold text-gray-900 dark:text-white">
{{$alum->nombre}} {{$alum->apellpatern}} {{$alum->apellmatern}}
</h3>
<button type="button" class="text-gray-400 bg-transparent hover:bg-gray-200 hover:text-gray-900 rounded-lg text-sm p-1.5 ml-auto inline-flex items-center dark:hover:bg-gray-600 dark:hover:text-white" data-modal-toggle="defaultModal">
<svg aria-hidden="true" class="w-5 h-5" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z" clip-rule="evenodd"></path></svg>
<span class="sr-only">Close modal</span>
</button>
</div>
<!-- Modal body -->
<div class="p-6 space-y-6">
<p class="text-base leading-relaxed text-gray-500 dark:text-gray-400">
With less than a month to go before the European Union enacts new consumer privacy laws for its citizens, companies around the world are updating their terms of service agreements to comply.
</p>
<p class="text-base leading-relaxed text-gray-500 dark:text-gray-400">
The European Union’s General Data Protection Regulation (G.D.P.R.) goes into effect on May 25 and is meant to ensure a common set of data rights in the European Union. It requires organizations to notify users as soon as possible of high-risk data breaches that could personally affect them.
</p>
</div>
<!-- Modal footer -->
<div class="flex items-center p-6 space-x-2 rounded-b border-t border-gray-200 dark:border-gray-600">
<button data-modal-toggle="defaultModal" type="button" class="text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800">I accept</button>
<button data-modal-toggle="defaultModal" type="button" class="text-gray-500 bg-white hover:bg-gray-100 focus:ring-4 focus:outline-none focus:ring-blue-300 rounded-lg border border-gray-200 text-sm font-medium px-5 py-2.5 hover:text-gray-900 focus:z-10 dark:bg-gray-700 dark:text-gray-300 dark:border-gray-500 dark:hover:text-white dark:hover:bg-gray-600 dark:focus:ring-gray-600">Decline</button>
</div>
</div>
</div>
</div>
#endforeach
But when i pressed the link it does not work, i am using data-target="#myModal{{$student->id }} in order to pass #student data to tailwind Main modal id="myModal{{$student->id}}",
it seems that this is not the proper way to pass data, i am using Laravel 8, anyhelp is appreciated
Thank you in advance
Omar

Unable to click on tile using Protractor

I am new user of Protractor. Need help as i am unable to click on Some Name, having below HTML
<div class="department-click"
<div class="department-click" onclick="GLOBAL_SERVICE_ID=405;changeLocation('#/aaaa');_routeFrom='home'">
<!-- <div class="department-click" onclick="changeLocation('#/aaaa')"> -->
<div class="department-icon custom-svgbg1 layout-column layout-align-center-center">
<!-- <svg style="height:80px; width:80px;" viewBox="0 0 24 24"> -->
<!-- <path fill="#fff" d="M12,3L1,9L12,15L21,10.09V17H23V9M5,13.18V17.18L12,21L19,17.18V13.18L12,17L5,13.18Z" /> -->
<!-- </svg> -->
<svg height="80px" viewBox="0 0 92.168 92.168" width="80px">
<rect clip-rule="evenodd" fill="none" fill-rule="evenodd" height="92.168" width="92.168" x="0"></rect>
<path d="M4.994,53.166V37.65l-3.248-1.418c-1.185-0.511-1.077-2.165,0.2-2.565l44.208-13.824 c0.255-0.091,0.566-0.091,0.821,0l44.244,13.915c1.26,0.4,1.26,2.182,0.019,2.6L47.123,55.385c-0.366,0.145-0.73,0.145-1.096-0.019 L7.731,38.832v14.352c1.022,0.219,1.86,0.673,2.554,1.309c2.499,2.257,2.573,6.312,1.807,9.351 c-0.766,2.947-2.482,5.802-5.018,7.403c-0.475,0.309-1.022,0.273-1.477-0.019c-2.592-1.618-4.361-4.456-5.146-7.366 c-0.802-3.036-0.711-7.021,1.752-9.293C2.968,53.875,3.899,53.384,4.994,53.166L4.994,53.166z M6.782,35.468 c0.091,0.017,0.183,0.053,0.255,0.091l39.556,17.096l40.322-17.388L46.557,22.57L6.18,35.195L6.782,35.468z M69.508,51.201 c0-0.745,0.602-1.365,1.368-1.365c0.749,0,1.368,0.619,1.368,1.365v10.532c0,5.22-6.951,8.531-15.781,9.894 c-6.495,1.001-13.74,1.037-20.233,0.019c-8.558-1.328-15.181-4.567-15.181-9.896V51.457c0-0.764,0.619-1.365,1.368-1.365 c0.747,0,1.368,0.6,1.368,1.365v10.294c0,3.675,5.619,6.076,12.863,7.204c6.221,0.982,13.172,0.945,19.395-0.019 c7.534-1.165,13.464-3.619,13.464-7.203V51.201z M3.096,63.17c0.547,2.018,1.643,3.983,3.248,5.257 c1.515-1.273,2.573-3.219,3.103-5.257c0.511-1.965,0.675-5.167-0.985-6.676c-1.151-1.018-3.286-0.945-4.397,0.072 C2.402,58.095,2.568,61.186,3.096,63.17L3.096,63.17z" fill="#3A3E49 "></path>
</svg>
</div>
<h3 class="clamp2">
<span>
Some Name
</span>
</h3>
</div>
Try locating the element by css:
element(by.css('.department-click .clamp2 span'));
Depends on which element you want to click, next line is locating the element by css and then clicking it:
element(by.css('h3.clamp2 span')).click();

How to change the color of custom svg icon in ionic 4?

I want to change the color of a custom svg icon on clicking a button
<ion-item>
<ion-icon src="../../assets/img/icon-qr.svg"></ion-icon>
<ion-label>Qr Scan</ion-label>
</ion-item>
I was unable to override an svg stroke or fill if it was specified in the svg.
Example: bad svg
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="16" viewBox="0 0 20 16">
<g fill="#88AACC" fill-rule="evenodd" stroke-linecap="round" stroke="#555555" stroke-linejoin="round" stroke-width="2">
...
</g>
</svg>
Removing fill="#88AACC" & stroke="#555555" from within the SVG itself then allowed it to be controlled from CSS as you'd expect.
.some-class {
fill: red;
stroke: blue;
}
If you remove the entire style attribute inside the path of your custom icon,
Ionic adds its default style instead.
<path
style="APPLIED STYLE"
d="DRAWN PATH"
/>
After removing the style attribute, the custom icon can be used like e.g. ionicons.
<IonIcon icon={CUSTOM_ICON} color="primary" />
Ionic sets the fill property of the svg when the color attribute is used. Stroke color e.g. if used for outline icons is not set.
its working fine see below
page.html
<ion-item>
<ion-icon src="/assets/images/box.svg" color="primary" style="fill: brown;"></ion-icon>
<ion-label>Qr Scan</ion-label>
</ion-item>
<ion-item>
<ion-icon src="/assets/images/boxing.svg" style="fill: brown;"></ion-icon>
<ion-label>Qr Scan</ion-label>
</ion-item>
for me only i had to remove fill property fill="#000000" from the svg file
``<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 60 60" style="enable-background:new 0 0 496 496;"
xml:space="preserve">
<g xmlns="http://www.w3.org/2000/svg">
<path ...... fill="#000000" />
<path ...... fill="#000000" />
<path ...... fill="#000000" />
and then on my Ion-icon i did like so
<ion-icon style="fill: white;" ></ion-icon>
that solved the issue

How can get the overflow menu option to be clicked using protractor

An overflow menu is using in the application:
OverflowMenu
I'm using Protractor to grab the menu and it's options, I can click and open the overflow menu but failed to click the options within overflow menu.
The HTML code for overflow menu and options:
<td class="bx--table-column-menu">
<div data-overflow-menu="" tabindex="0" aria-label="Overflow menu description" class="bx--overflow-menu" carbon-overflow-menu="" aria-expanded="false">
<svg class="bx--overflow-menu__icon" width="16" height="16" viewBox="0 0 16 16" aria-hidden="true">
<circle cx="8" cy="3" r="1"></circle>
<circle cx="8" cy="8" r="1"></circle>
<circle cx="8" cy="13" r="1"></circle>
</svg>
<ul class="bx--overflow-menu-options bx--overflow-menu--flip" data-floating-menu-direction="bottom">
<li class="bx--overflow-menu-options__option bx--table-row--menu-option">
<button class="bx--overflow-menu-options__btn" ng-click="vm.dealSelected(data)"> <div class="bx--overflow-menu-options__option-content">
<span>Open Opportunity</span>
</div>
</button>
</li>
<li class="bx--overflow-menu-options__option bx--table-row--menu-option ng-scope" ng-if="(data.accesslist[0].authtype | lowercase ) == 'admin'">
<button class="bx--overflow-menu-options__btn" ng-click="vm.dealSelectedAction(data, 'app.modify-project')">
<div class="bx--overflow-menu-options__option-content">
<span>Modify Opportunity</span>
</div>
</button>
</li><!-- end ngIf: (data.accesslist[0].authtype | lowercase ) == 'admin' -->
...
In Web Developer -> Inspector view, I noticed that the code below tag "ul" is grey.
I verified XPath for the menu options by add-ons TX of Firefox, the XPath is:
//td[#class='bx--table-column-menu']/div/ul/li/button/div/span[contains(text(),'Open Opportunity')]
As result of execution, I got Count: 1 successfully
I'm trying to use following codes to grab and click option in overflow menu:
element(by.xpath("//td[#class='bx--table-column-menu']/div/ul/li/button/div/span[contains(text(),'Open Opportunity')]")).click();
I got error message:
No element found using locator: By(xpath, //td[#class='bx--table-column-menu']/div/ul/li/button/div/span[contains(text(),'Open Opportunity')])
If the li item is grey it means the element is not displayed. Hence click is not working.
After opening the overflow menu wait till element.isDiplayed(), then try the click.

Relative path links are not working in iphone

I created an SVG menu for a single page website. When I use the menu from my computer everything works fine, but when I try to access from my phone, the links are not working. I noticed that the issue only happens if I use relative paths (I am only linking to the Id of the element) and with Iphones, I don’t have any issues with Android devices. My problem is that if I use absolute paths, I lose the scroll-behavior animation (smooth).
I don't know if this is issue with my SVG or that I simply can't use relative path in iphones.
This is the link for my project: http://portfolio-2019-cg.herokuapp.com
I am using React to create this website.
<div>
<svg className="circle" width="611px" onClick={this.showMenu} height="883px" viewBox="0 0 611 883" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlnsXlink="http://www.w3.org/1999/xlink">
<g id="Page-1" stroke="none" strokeWidth="1" fill="none" fillRule="evenodd">
<path id='menu' className={this.state.activeclass} d="M611,473 L611,708 C611,804.649831 532.649831,883 436,883 L269,883 L60,883 C26.862915,883 1.11635499e-14,856.137085 7.10542736e-15,823 L1.08387875e-15,473 L-1.42108547e-14,60 C-1.82689772e-14,26.862915 26.862915,6.08718376e-15 60,0 L551,0 C584.137085,-6.08718376e-15 611,26.862915 611,60 L611,473 Z" id="Combined-Shape" fill="#FF531B"></path>
<circle id="Oval" fill="#FF531B" cx="436" cy="708" r="175"></circle>
<path className={this.state.plusclass} onClick={this.showMenu} d="M486,658.5 L561.5,658.5 L561.5,758.5 L486,758.5 L486,834 L386,834 L386,758.5 L310.5,758.5 L310.5,658.5 L386,658.5 L386,583 L486,583 L486,658.5 Z" id="Combined-Shape" fill="#080815"></path>
<g className={this.state.menuclass}>
<text id="HOME" fontSize="94" fontWeight="normal" fill="#080815">
<a xlinkHref="#home">
<tspan x="205.181641" y="140">Home</tspan>
</a>
</text>
<text id="ABOUT" fontSize="94" fontWeight="normal" fill="#080815">
<a xlinkHref="#about">
<tspan x="176.977051" y="270">About</tspan>
</a>
</text>
<text id="PORTFOLIO" fontSize="94" fontWeight="normal" fill="#080815">
<a xlinkHref="#portfolio">
<tspan x="64.1586914" y="400">Portfolio</tspan>
</a>
</text>
<text id="CONTACT" fontSize="94" fontWeight="normal" fill="#080815">
<a xlinkHref="#contact">
<tspan x="120.567871" y="530">Contact</tspan>
</a>
</text>
</g>
</g>
</svg>
</div>