How to use el.isSelected method in Appium Xcuitest Driver

Best JavaScript code snippet using appium-xcuitest-driver

UK-TC-Package-Journey.js

Source:UK-TC-Package-Journey.js Github

copy

Full Screen

...103 // Fill in the Form Data104 .then(function() {105 log(6, 'Fill In form Data');106 return $browser.waitForAndFindElement(By.xpath("//select[@id=\'title\']//option[2]"), DefaultTimeout); })107 .then(function(el) { el.isSelected()108 .then(function(bool) { if (!bool) { el.click(); } });109 })110 // First Name111 .then(function() {112 return $browser.waitForAndFindElement(By.id("name"), DefaultTimeout);113 })114 .then(function (el) {115 el.clear();116 el.sendKeys("Test");117 })118 // Last Name119 .then(function() {120 return $browser.waitForAndFindElement(By.id("surname"), DefaultTimeout); })121 .then(function (el) {122 el.clear();123 el.sendKeys("Test");124 })125 // Email126 .then(function() {127 return $browser.waitForAndFindElement(By.id("email"), DefaultTimeout);128 })129 .then(function (el) {130 el.clear();131 el.sendKeys("analytics@thomascookonline.com");132 })133 // Lead Pax Email134 .then(function() {135 return $browser.waitForAndFindElement(By.id("leadPassengerConfirmEmail"), DefaultTimeout);136 })137 .then(function (el) {138 el.clear();139 el.sendKeys("analytics@thomascookonline.com");140 })141 // Post Code142 .then(function() {143 return $browser.waitForAndFindElement(By.id("postCode"), DefaultTimeout);144 })145 .then(function (el) {146 el.clear();147 el.sendKeys("EC1A 4HD");148 })149 // Find Address Button Click150 .then(function() {151 return $browser.waitForAndFindElement(By.linkText("Find address"), DefaultTimeout);152 })153 .then(function (el) { el.click(); })154 // Address Select155 .then(function() {156 return $browser.waitForAndFindElement(By.xpath("//select[@id=\'addressSelect\']//option[2]"), DefaultTimeout); })157 .then(function(el) { el.isSelected()158 .then(function(bool) { if (!bool) { el.click(); } });159 })160 // Day of DOB161 .then(function() {162 return $browser.waitForAndFindElement(By.xpath("//select[@id=\'day\']//option[2]"), DefaultTimeout);163 })164 .then(function(el) { el.isSelected()165 .then(function(bool) { if (!bool) { el.click(); } });166 })167 // Month of DOB168 .then(function() {169 return $browser.waitForAndFindElement(By.xpath("//select[@id=\'month\']//option[2]"), DefaultTimeout);170 })171 .then(function(el) { el.isSelected()172 .then(function(bool) { if (!bool) { el.click(); } });173 })174 // Year of DOB175 .then(function() {176 return $browser.waitForAndFindElement(By.xpath("//select[@id=\'year\']//option[29]"), DefaultTimeout);177 })178 .then(function(el) { el.isSelected()179 .then(function(bool) { if (!bool) { el.click(); } });180 })181 // Contact Number182 .then(function() {183 return $browser.waitForAndFindElement(By.id("contactNumber"), DefaultTimeout);184 })185 .then(function (el) {186 el.clear();187 el.sendKeys("07400000000");188 })189 // Info Checkbox190 .then(function() {191 return $browser.waitForAndFindElement(By.xpath("//div[@class=\'checkbox\']/label/input"), DefaultTimeout); })192 .then(function(el) { el.isSelected()193 .then(function(bool) { if (bool) { el.click(); } });194 })195 // Form Filling Complete196 // ----------------------------------------------------------------------------------------------------------------197 /*198 * Step 7: Go to Other Pax Details199 */200 .then(function() {201 log(7, 'clickElement "Continue"');202 return $browser.waitForAndFindElement(By.linkText("Continue"), DefaultTimeout); })203 .then(function (el) { el.click(); })204 /*205 * Step 8: Fill in Additional Pax Info206 */207 .then(function() {208 log(8, 'Form Fill Additional Pax');209 return $browser.waitForAndFindElement(By.xpath("//select[@id=\'title2Room1\']//option[4]"), DefaultTimeout); })210 .then(function(el) { el.isSelected()211 .then(function(bool) { if (!bool) { el.click(); } }); })212 .then(function() {213 return $browser.waitForAndFindElement(By.id("name2Room1"), DefaultTimeout); })214 .then(function (el) {215 el.clear();216 el.sendKeys("Test"); })217 .then(function() {218 return $browser.waitForAndFindElement(By.id("surname2Room1"), DefaultTimeout); })219 .then(function (el) {220 el.clear();221 el.sendKeys("Test"); })222 .then(function() {223 return $browser.waitForAndFindElement(By.xpath("//select[@id=\'day2Room1\']//option[4]"), DefaultTimeout); })224 .then(function(el) { el.isSelected()225 .then(function(bool) { if (!bool) { el.click(); } }); })226 .then(function() {227 return $browser.waitForAndFindElement(By.xpath("//select[@id=\'day2Room1\']//option[2]"), DefaultTimeout); })228 .then(function(el) { el.isSelected()229 .then(function(bool) { if (!bool) { el.click(); } }); })230 .then(function() {231 return $browser.waitForAndFindElement(By.xpath("//select[@id=\'month2Room1\']//option[2]"), DefaultTimeout); })232 .then(function(el) { el.isSelected()233 .then(function(bool) { if (!bool) { el.click(); } }); })234 .then(function() {235 return $browser.waitForAndFindElement(By.xpath("//select[@id=\'year2Room1\']//option[34]"), DefaultTimeout); })236 .then(function(el) { el.isSelected()237 .then(function(bool) { if (!bool) { el.click(); } }); })238 // Form Filling Additional Pax - Complete239 /*240 * Step 9: Go to Payment Details Page241 */242 .then(function() {243 log(9, 'Pax Details Submit');244 return $browser.waitForAndFindElement(By.id("paxSubmit"), DefaultTimeout); })245 .then(function (el) { el.click(); })246 /*247 * Step 10: Submit Card Details248 */249 .then(function() {250 log(10, 'clickElement "submit-card-details"');...

Full Screen

Full Screen

billMenu.js

Source:billMenu.js Github

copy

Full Screen

1import { getAllMenu } from './menuUtility';2import { loaderDisplay } from './util';3let workData;4let selectionData;5let curCategorySel;6const getTotal = function () {7 let totalAmt = 0;8 selectionData.forEach(function (el) {9 totalAmt += el.total;10 });11 return totalAmt;12};13const renderSummary = function (count, total) {14 const html = `<p>Selected Items : <span class="bill-selection-count">${count}</span></p><p>Selected Price : <span class="bill-selection-price">${total}</span></p>`;15 const menuSummary = document.querySelector('.bill-selection-info__result');16 menuSummary.innerHTML = '';17 menuSummary.insertAdjacentHTML('afterbegin', html);18};19const renderBillMenu = () => {20 const categoryData = workData.filter(function (el) {21 return el.category === curCategorySel;22 });23 const markup = categoryData24 .map(function (el) {25 return `26 <div class="bill-menu-item__wrapper ${27 el.isSelected ? 'menu-checked' : ''28 }" data-id = ${el._id}>29 <div class="bill-menu-item" data-id = ${el._id}>30 <input type="checkbox" class="menu-select" ${31 el.isSelected ? 'checked' : ''32 }/>33 <p class="bill-menu-item__title">${el.item}</p>34 <p class="bill-menu-item__qty">${el.qty}</p>35 <p class="bill-menu-item__amount">${el.price}</p>36 37 <div class="inputQty_wrapper">38 <span>Pcs</span>39 40 <input41 type="number"42 id="menu-item__inputQty"43 class="menu-item__inputQty"44 value = ${el.inputQty}45 ${!el.isSelected ? 'disabled' : ''}46 ${!el.qty ? 'disabled' : ''}47 />48 </div>49 50 <div class="inputPlate_wrapper">51 <span>Plt</span>52 <input53 type="number"54 id="menu-item__inputPlate"55 class="menu-item__inputPlate"56 value = ${el.inputPlt}57 ${!el.isSelected ? 'disabled' : ''}58 />59 </div>60 </div>61 <input62 type="text"63 id="menu-item__total"64 class="menu-item__total"65 value=${el.total}66 disabled="disabled"67 />68 </div>69 `;70 })71 .join('');72 const billMenuContainer = document.querySelector('.bill-menu-items');73 billMenuContainer.innerHTML = '';74 billMenuContainer.insertAdjacentHTML('afterbegin', markup);75};76const setMenuSelection = (id) => {77 let count = 0;78 let total = 0;79 workData.forEach(function (el) {80 if (el._id == id) {81 if (el.isSelected) {82 el.isSelected = false;83 el.inputQty = 0;84 el.inputPlt = 0;85 el.total = 0;86 } else el.isSelected = true;87 }88 if (el.isSelected) {89 count = count + 1;90 total += el.total;91 }92 });93 renderBillMenu();94 renderSummary(count, total);95};96const updatePrice = (value, attribute, id, totalInput) => {97 let total = 0;98 let sCount = 0;99 let sTotal = 0;100 workData.forEach(function (el) {101 if (el._id == id) {102 const price = el.price;103 const qty = el.qty;104 if (attribute === 'qty') {105 total = Math.round((price / qty) * value);106 el.inputQty = value * 1;107 } else {108 total = Math.round(price * value);109 el.inputPlt = value * 1;110 }111 el.total = total;112 }113 totalInput.value = total;114 if (el.isSelected) {115 sCount = sCount + 1;116 sTotal += el.total;117 }118 });119 renderSummary(sCount, sTotal);120};121const updateReviewPrice = function (e) {122 if (e.target.classList.contains('inputReviewAmt')) {123 const id = e.target.parentElement.dataset.id;124 selectionData.forEach(function (el) {125 if (el._id == id) {126 el.total = e.target.value * 1;127 }128 });129 const reviewAmount = document.querySelector('.reviewAmount');130 reviewAmount.innerHTML = `Rs ${getTotal()}`;131 }132};133const renderReview = () => {134 selectionData = workData.filter(function (el) {135 return el.isSelected === true;136 });137 const reviewItems = document.querySelector('.bill-review-price-items');138 const reviewAmount = document.querySelector('.reviewAmount');139 reviewItems.innerHTML = '';140 const markup = selectionData141 .map(function (el) {142 return `143 <div class="bill-review-price-item">144 <p class= ${145 el.inputQty > 0 && el.inputPlt > 0 ? 'review-error' : ''146 }>${el.item} [${el.price}]</p>147 <p class= ${148 el.inputQty > 0 && el.inputPlt > 0 ? 'review-error' : ''149 }>${el.inputQty} Pieces</p>150 <div class="bill-review-price " data-id = ${el._id}>151 <span>Rs</span><input type="number" name="" id="" value="${152 el.total153 }" class = "inputReviewAmt"/>154 </div>155 </div>156 `;157 })158 .join('');159 reviewItems.insertAdjacentHTML('afterbegin', markup);160 reviewAmount.innerHTML = getTotal();161};162const getCompliment = (e) => {163 if (e.target.checked) {164 const comp = {165 _id: e.target.dataset.id,166 item: e.target.value,167 price: 0,168 qty: 0,169 category: 'complimentary',170 total: 0,171 };172 selectionData.push(comp);173 } else {174 selectionData = selectionData.filter(function (el) {175 return el._id != e.target.dataset.id;176 });177 }178};179const getFinalReciept = () => {180 const finalReceipt = document.querySelector('.bill-final-receipts');181 const html = selectionData182 .map(function (el) {183 return `184 <div class="bill-final-receipt">185 <p class=${el.total === 0 ? 'comp' : ''}>${el.item} </p>186 <p>Rs ${el.total}</p>187 </div>188 `;189 })190 .join('');191 finalReceipt.innerHTML = '';192 finalReceipt.insertAdjacentHTML('afterbegin', html);193 document.querySelector('.bill-final-total').innerHTML = `Rs ${getTotal()}`;194};195const billInit = async () => {196 loaderDisplay();197 const data = await getAllMenu();198 workData = data.map(function (el) {199 return { ...el, isSelected: false, inputQty: 0, inputPlt: 0, total: 0 };200 });201 loaderDisplay();202 //Add All Event Listener203 const billCategory = document.getElementById('bill-category');204 billCategory.addEventListener('change', function (e) {205 curCategorySel = billCategory.value;206 renderBillMenu();207 });208 // Check Box209 const billMenuItems = document.querySelector('.bill-menu-items');210 billMenuItems.addEventListener('change', function (e) {211 if (e.target.classList.contains('menu-select')) {212 const parentElem = e.target.parentElement.parentElement;213 parentElem.classList.toggle('menu-checked');214 setMenuSelection(parentElem.dataset.id);215 }216 });217 //Input218 billMenuItems.addEventListener('input', function (e) {219 if (e.target.classList.contains('menu-item__inputQty')) {220 const input =221 e.target.parentNode.parentNode.parentNode.querySelector(222 '.menu-item__total'223 );224 const parentElem = e.target.parentElement.parentElement;225 updatePrice(e.target.value, 'qty', parentElem.dataset.id, input);226 }227 if (e.target.classList.contains('menu-item__inputPlate')) {228 const input =229 e.target.parentNode.parentNode.parentNode.querySelector(230 '.menu-item__total'231 );232 const parentElem = e.target.parentElement.parentElement;233 updatePrice(e.target.value, 'plate', parentElem.dataset.id, input);234 }235 });236 //Review Button237 const reviewBtn = document.querySelector('.review-cta');238 const reviewPrevBtn = document.querySelector('.review-prev');239 const billCtaContainer = document.querySelector('.bill-container');240 const billReviewContainer = document.querySelector('.bill-review-container');241 const billReviewItems = document.querySelector('.bill-review-price-items');242 const complimentItems = document.querySelector('.bill-compliment-items');243 const reviewNextBtn = document.querySelector('.review-next');244 const receiptContainer = document.querySelector('.bill-receipt-container');245 const recieptPrevBtn = document.querySelector('.receipt-prev');246 //Review Button247 reviewBtn.addEventListener('click', function (e) {248 billCtaContainer.classList.toggle('hidden');249 billReviewContainer.classList.toggle('hidden');250 renderReview();251 });252 //Review Prev Button253 reviewPrevBtn.addEventListener('click', function (e) {254 billCtaContainer.classList.toggle('hidden');255 billReviewContainer.classList.toggle('hidden');256 });257 //Review Input Button258 billReviewItems.addEventListener('input', updateReviewPrice);259 //Complement Checks260 complimentItems.addEventListener('change', getCompliment);261 //Next button Review262 reviewNextBtn.addEventListener('click', function (e) {263 billReviewContainer.classList.toggle('hidden');264 receiptContainer.classList.toggle('hidden');265 getFinalReciept();266 });267 //Prev Button Receipt268 recieptPrevBtn.addEventListener('click', function (e) {269 billReviewContainer.classList.toggle('hidden');270 receiptContainer.classList.toggle('hidden');271 });272};...

Full Screen

Full Screen

StatisticalCartMobile.js

Source:StatisticalCartMobile.js Github

copy

Full Screen

1import React,{useState} from 'react'2import { ScrollPanel } from 'primereact/scrollpanel';3import { CircularProgressbar } from 'react-circular-progressbar';4import './statisticalCartMobile.css'5import 'react-circular-progressbar/dist/styles.css';6function StatisticalCartMobile({cartStatistical}) {7 const [action] = useState([8 {9 action: "action 1"10 },11 {12 action: "action 2"13 },14 {15 action: "action 3"16 },17 {18 action: "action 4"19 }20 ])21 const [cart, setCart] = useState(cartStatistical)22 const openSelectedStatisticCard = (id) => {23 setCart(cart.map((el, i) => (el.id === id ? { ...el, isSelected: true } : { ...el, isSelected: false })))24 }25 const closeSelectedStatisticCard=(id)=>{26 setCart(cart.map((el,i)=>(el.id===id?{...el,isSelected:false}:{ ...el, isSelected: false })))27 }28 return (29 <div className="p-grid mr">30 31 32 <div className="p-col-12 mr ">33 34 {cart.map((el, index) => (35 <ScrollPanel className="custombar2"id="p-scrollpanel-content" key={index}>36 <div key={el.id} className="p-grid p-col-12 p-md-12 p-lg-12 mr container-cart " id="container-cart-mobile" >37 <div className=" p-col-4 p-md-4 p-lg-4 container-ref-title-cart">38 <span className="ref-cart">{el.ref}</span>39 <span className="title-cart">{el.title}</span>40 <div className="container-social-media-cart">41 <i className="pi pi-facebook icon-facebook-cart"></i>42 <i className="pi pi-camera icon-instagram-cart"></i>43 <i className="pi pi-twitter icon-twitter-cart"></i>44 </div>45 </div>46 <div className="p-col container-icon-price-title-cart"style={{marginLeft:"25px"}}>47 <i className="pi pi-chart-bar icon-chart-bar-cart"></i>48 <div className="container-price-title-cart">49 <span>${el.price}</span>50 <span>Conversion</span>51 </div>52 </div>53 <div className="p-col container-icon-price-title-cart" style={{marginLeft:"25px"}}>54 <i className="pi pi-eye icon-eye-cart"></i>55 <div className="container-price-title-cart">56 <span>{el.view}K</span>57 <span>Engagement</span>58 </div>59 </div>60 <div className="p-col container-icon-price-title-cart" style={{marginLeft:"25px"}}>61 <i className="pi pi-thumbs-up icon-thumbs-up-cart"></i>62 <div className="container-price-title-cart">63 <span>{el.like}K</span>64 <span>Likes</span>65 </div>66 </div>67 <div className="p-col container-icon-price-title-cart" style={{marginLeft:"25px"}}>68 <i className="pi pi-comment icon-comment-cart"></i>69 <div className="container-price-title-cart">70 <span>{el.comment}</span>71 <span>Comments</span>72 </div>73 </div>74 <div className="p-col-2 icon-chart-percentage-cart" style={{marginLeft:"25px"}}>75 <CircularProgressbar value={el.percentage} text={`${el.percentage}%`} style={{ stroke: "blue" }} />76 </div>77 <div className="casc p-col " key={index} onClick={() =>el.isSelected?closeSelectedStatisticCard(el.id): openSelectedStatisticCard(el.id)}>78 <div>79 <i className="pi pi-ellipsis-v p-col-3 p-md-3 p-lg-3 " style={{marginRight:"25px"}}></i>80 </div>81 {el.isSelected &&82 <div className="p-col container-open-action">83 { action.map((el, i) => (84 <div className="open-action" key={i}>85 <span>{el.action}</span>86 </div>87 ))}88 </div>89 }90 </div>91 </div>92 </ScrollPanel>93 ))}94 95 </div>96 </div>97 )98}...

Full Screen

Full Screen

SelectBestNineComp.jsx

Source:SelectBestNineComp.jsx Github

copy

Full Screen

1import { useState, useEffect } from "react";2import { useHistory } from "react-router-dom";3import { fetchSelectedPhotos, fetchAllPhotos } from "../../../api/photosAPI";4import Card from "../../common/card/Card";5import Preloading from "../../common/Preloading";6import ContinueBtn from "./continue-btn/ContinueBtn";7function SelectBestNineComp(props) {8 const [photos, setPhotos] = useState(9 sessionStorage.getItem("all_photos")10 ? JSON.parse(sessionStorage.getItem("all_photos"))11 : []12 );13 const [preLoading, setPreLoading] = useState(true);14 const history = useHistory();15 useEffect(() => {16 // get all photos17 fetchAllPhotos(18 (data) => {19 // adding isSelected object key and value (Eg. isSelected: false)20 const arr = addIsSelected(data.data.entries);21 setPhotos(arr);22 // store all photos in session storage23 sessionStorage.setItem("all_photos", JSON.stringify(arr));24 let arragedArr = [];25 // check if there selected photos in session storage26 if (sessionStorage.getItem("selected_photos")) {27 const selectedStoredPhotos = JSON.parse(28 sessionStorage.getItem("selected_photos")29 );30 arragedArr = gettingSelectedPhotos(arr, selectedStoredPhotos);31 setPhotos(arragedArr);32 setPreLoading(false);33 } else {34 fetchSelectedPhotos(35 (data) => {36 const selectedPhotos = data.data[0].photos;37 arragedArr = gettingSelectedPhotos(arr, selectedPhotos);38 setPhotos(arragedArr);39 setPreLoading(false);40 },41 (error) => {42 setPreLoading(false);43 }44 );45 }46 },47 (error) => {48 setPreLoading(false);49 }50 );51 }, []);52 // setting isSelected as default (Eg. isSelected: false)53 const addIsSelected = (data) => {54 let photoArr = [];55 data.forEach((el) => {56 const obj = el;57 obj["isSelected"] = false;58 photoArr = [...photoArr, obj];59 });60 return photoArr;61 };62 // setting isSelected photos (Eg. isSelected: true)63 const gettingSelectedPhotos = (arr, selectedPhotos) => {64 selectedPhotos.forEach((sel) => {65 arr.filter((el) => {66 if (el.id === sel.id) {67 el["isSelected"] = true;68 return el;69 } else {70 return el;71 }72 });73 });74 return arr;75 };76 // function to handle selection and de-selection77 const handleSelections = (id) => {78 const filteredPhotos = photos.filter((el) => {79 if (el.id === id) {80 if (el.isSelected) {81 el["isSelected"] = false;82 } else {83 el["isSelected"] = true;84 }85 }86 return el;87 });88 setPhotos(filteredPhotos);89 };90 // get all selected photos91 const isSelected = photos.filter((el) => el.isSelected === true);92 if (isSelected.length > 0) {93 sessionStorage.setItem("selected_photos", JSON.stringify(isSelected));94 }95 // continue96 const handleContine = () => {97 sessionStorage.setItem("selected_photos", JSON.stringify(isSelected));98 history.push("/change-order");99 };100 return (101 <div className="container-cus px-0">102 <div className="row m-0">103 <div className="col p-0 con-min-height">104 {!preLoading ? (105 <>106 <div className="sticky-header">107 <h3 className="main-heading" data-testid="photo-counter">108 Select Your Best 9 photos109 </h3>110 <p className="photo-count" data-testid="photos-count">111 Photos : {isSelected.length}112 </p>113 <button114 type="button"115 className="btn back-btn"116 onClick={() => history.push("/")}117 >118 <i className="fas fa-angle-left" style={{ fontSize: 14 }}></i>{" "}119 Back120 </button>121 <ContinueBtn122 len={isSelected.length}123 handleContine={handleContine}124 />125 </div>126 <div className="grid">127 {photos.map((el, i) => (128 <Card129 data={el}130 key={i}131 handleSelections={handleSelections}132 isSelApplicable={true}133 />134 ))}135 </div>136 </>137 ) : (138 <Preloading />139 )}140 </div>141 </div>142 </div>143 );144}...

Full Screen

Full Screen

testingSlice.js

Source:testingSlice.js Github

copy

Full Screen

1/* eslint-disable no-param-reassign */2import { createSlice } from '@reduxjs/toolkit'3import { getFromLocalStorage } from '../utils/helpers/storageHelper'4import { getQuizFormData } from './asyncFunctions'5const selectedQuiz = getFromLocalStorage('@quiz')6const initialState = {7 status: 'pending',8 quizes: [],9 selectedQuiz: selectedQuiz || {},10 checking: {11 quantity: 0,12 point: 0,13 enteredAnswers: [],14 },15 count: 0,16 showScore: false,17 showAlert: false,18 isSelectedAnswer: false,19}20export const testingSlice = createSlice({21 name: 'testing',22 initialState,23 reducers: {24 selectQuizTest(state, actions) {25 const { quiz } = actions.payload26 state.selectedQuiz = quiz27 },28 gotoNextQuestion(state) {29 const question = state.selectedQuiz.quizeForms30 if (state.count + 1 === question.length) {31 state.showScore = true32 state.count = 033 } else if (34 question[state.count].isQuestionImportant &&35 !state.isSelectedAnswer36 ) {37 state.showAlert = true38 } else {39 state.count += 140 }41 },42 selectAnswerMultupal(state, actions) {43 const question = state.selectedQuiz.quizeForms44 const { answerId, answerCount } = actions.payload45 state.isSelectedAnswer = true46 const selectedVariant = question[state.count].answerItems.map((el) => {47 if (el.isVariantCorrect && el.id === answerId) {48 // eslint-disable-next-line no-param-reassign49 el.isSelected = true50 if (answerCount === 1 || answerCount === 0) {51 state.checking.quantity += 152 state.checking.point += 1053 } else {54 state.checking.quantity += 0.555 state.checking.point += 556 }57 } else if (el.id === answerId) {58 // eslint-disable-next-line no-param-reassign59 el.isSelected = true60 }61 return el62 })63 question[state.count].answerItems = selectedVariant64 },65 selectAnswerOneVariant(state, actions) {66 const question = state.selectedQuiz.quizeForms67 const { answerId, answerCount } = actions.payload68 const selectedVariant = question[state.count].answerItems.map((el) => {69 // eslint-disable-next-line no-param-reassign70 el.isSelected = false71 if (72 el.isVariantCorrect &&73 el.id === answerId &&74 answerCount + 1 === 175 ) {76 state.isSelectedAnswer = true77 state.checking.quantity += 178 state.checking.point += 1079 el.isSelected = true80 } else if (el.id === answerId) {81 el.isSelected = true82 }83 return el84 })85 state.isSelectedAnswer = true86 question[state.count].answerItems = selectedVariant87 },88 saveInputsValue(state, actions) {89 state.isSelectedAnswer = true90 const { enteredValue, question } = actions.payload91 state.checking.enteredAnswers.push({92 question,93 answerToQuestion: enteredValue,94 id: Date.now().toString(),95 })96 },97 closeScore(state) {98 state.showScore = false99 },100 showAlert(state) {101 state.isSelectedAnswer = false102 state.showAlert = false103 },104 },105 // -------extra reducers-----------106 extraReducers: {107 [getQuizFormData.pending]: (state) => {108 state.status = 'loading'109 },110 [getQuizFormData.fulfilled]: (state, actions) => {111 state.status = 'resolved'112 state.quizes = actions.payload113 },114 },115})...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

1import './style.css'2import screen from './screen.svg'3const NS = 'http://www.w3.org/2000/svg'4document.querySelector('#svg-container').innerHTML = screen5const lines = document.querySelectorAll('g')6const elScroll = document.querySelector('#scroll')7const elMinimap = document.querySelector('#minimap')8const elThumb = document.querySelector('#thumb')9const handleClick = e => {10 const el = e.target11 const elText = document.querySelector(`#${el.dataset.info}`)12 el.isSelected = !el.isSelected13 if (el.isSelected) {14 elText.classList.add('selected')15 el.style.fill = '#ffcc00'16 el.style.stroke = '#666666'17 el.style.strokeWidth = '2px'18 }19 else {20 elText.classList.remove('selected')21 el.style.fill = '#ebebeb'22 el.style.stroke = '#000'23 el.style.strokeWidth = '1px'24 }25 console.log(el.dataset.info, el.isSelected)26}27lines.forEach((line, i) => {28 const letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'29 const seats = line.querySelectorAll('path')30 seats.forEach((seat, j) => {31 let position = seat.getBoundingClientRect()32 let elText = document.createElementNS(NS, 'text')33 let seatId = letters[i] + (j + 1)34 elText.textContent = seatId35 elText.id = seatId36 const zoomFactor = 2.131537 elText.setAttribute('x', position.x * zoomFactor + 19)38 elText.setAttribute('y', position.y * zoomFactor - 30)// + 25)39 elText.setAttribute('text-anchor', 'middle')40 seat.addEventListener('click', handleClick)41 seat.dataset.info = seatId42 line.appendChild(elText);43 })44})45elScroll.addEventListener('scroll', e => {46 const realWidth = 600;47 const miniWidth = 140; //elMinimap.clientWidth48 const percentLeft = e.target.scrollLeft / (realWidth + elScroll.clientWidth)49 const miniLeft = miniWidth * percentLeft50 renderThumb(miniLeft)51})52window.addEventListener('resize', () => renderThumb(0))53const renderThumb = (left) => {54 const realWidth = 600;55 const viewportScale = elScroll.clientWidth / realWidth56 elThumb.style.width = `${viewportScale * 100}px`57 elThumb.style.left = `${left}px`58}...

Full Screen

Full Screen

NavMenu.js

Source:NavMenu.js Github

copy

Full Screen

1import React, { useState } from 'react'2import useWindowSize from '../use window size/UseWindowSize'3import './navMenu.css'4function NavMenu() {5 const [menuItems, setmenuItems] = useState([6 {7 id: "1",8 isSelected: false,9 icon: "pi pi-bell pi-th-large icon-menu"10 },11 {12 id: "2",13 isSelected: true,14 icon: "pi pi-bell pi-bookmark icon-menu"15 },16 {17 id: "3",18 isSelected: false,19 icon: "pi pi-bell pi-chart-bar icon-menu"20 },21 {22 id: "4",23 isSelected: false,24 icon: "pi pi-bell pi-calendar-minus icon-menu"25 },26 {27 id: "5",28 isSelected: false,29 icon: "pi pi-bell pi-clone icon-menu"30 }31 ])32 const { width } = useWindowSize();33 const changeSelectedMenu = (id) => {34 setmenuItems( menuItems.map((el, i) => (el.id === id ? { ...el, isSelected: true } : { ...el, isSelected: false })))35 }36 return (37 <div>38 <div className={(width<1160&&width>768)?"p-grid p-dir-col mr container-nav-menu-spec":"p-grid p-dir-col container-nav-menu mr"}>39 <div className="p-col ">40 <span className="logo">LOGO</span>41 </div>42 {menuItems.map((el, i) => (43 <div key={i} onClick={() => changeSelectedMenu(el.id)} className={`p-col container-icon-menu ${el.isSelected44 && "p-col selected-menu-item"45 }`}>46 <i className={`${el.icon} ${el.isSelected && "change-color-icon-menu"}`}></i>47 {/* {el.isSelected&&<p style={{marginLeft:"200px"}}>xx</p>} */}48 </div>49 ))}50 </div>51 </div>52 )53}...

Full Screen

Full Screen

GameBox.js

Source:GameBox.js Github

copy

Full Screen

1import React from "react";2import { Div } from "../Grid/Grid";3import { useLocation } from "react-router-dom";4import "./GameBox.scss";5const GameBox = (props) => {6 const { boxes, destroyed, selectedBoxHandler } = props;7 const { hash } = useLocation();8 return (9 <Div className="gameBox">10 {boxes.map((el, index) => {11 const boxClasses = ["smallBox"];12 if (el.isSelected) {13 boxClasses.push("isSelected");14 }15 if (destroyed) {16 boxClasses.push("isSelected");17 }18 if (destroyed && !el.isBomb) {19 boxClasses.push("fadeAway");20 }21 return (22 <Div23 className="smallBoxWrapper"24 key={index}25 onClick={() => (!el.isSelected ? selectedBoxHandler(el.id) : {})}26 >27 <Div className={boxClasses.join(" ")}>28 {hash === "#win-mode" && el.isBomb && <b>B</b>}29 {!el.isSelected && !destroyed && (30 <Div className="scaryEmoji emoji">😨</Div>31 )}32 {!el.isBomb && <Div className="mainEmoji emoji">😊</Div>}33 {el.isBomb && <Div className="mainEmoji emoji">💥</Div>}34 </Div>35 </Div>36 );37 })}38 </Div>39 );40};...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const wdio = require('webdriverio');2const assert = require('assert');3const opts = {4 desiredCapabilities: {5 }6};7async function main () {8 const client = await wdio.remote(opts);9 const status = await el.isSelected();10 console.log(status);11 if (!status) {12 await el.click();13 }14 const status2 = await el.isSelected();15 console.log(status2);16 if (status2) {17 await el.click();18 }19 const status3 = await el.isSelected();20 console.log(status3);21 assert.equal(status3, false);22 await client.deleteSession();23}24main();

Full Screen

Using AI Code Generation

copy

Full Screen

1const el = await driver.$('~Switch');2const isSelected = await el.isSelected();3console.log(isSelected);4const el = await driver.$('~Switch');5const isSelected = await el.getAttribute('value');6console.log(isSelected);7const el = await driver.$('~Switch');8const isSelected = await el.getAttribute('selected');9console.log(isSelected);10const el = await driver.$('~Switch');11const isSelected = await el.getAttribute('enabled');12console.log(isSelected);13const el = await driver.$('~Switch');14const isSelected = await el.getAttribute('visible');15console.log(isSelected);16const el = await driver.$('~Switch');17const isSelected = await el.getAttribute('accessible');18console.log(isSelected);19const el = await driver.$('~Switch');20const isSelected = await el.getAttribute('accessibilityContainer');21console.log(isSelected);22const el = await driver.$('~Switch');23const isSelected = await el.getAttribute('accessibilityLabel');24console.log(isSelected);25const el = await driver.$('~Switch');26const isSelected = await el.getAttribute('accessibilityValue');27console.log(isSelected);28const el = await driver.$('~Switch');29const isSelected = await el.getAttribute('accessibilityHint');30console.log(isSelected);31const el = await driver.$('~Switch');32const isSelected = await el.getAttribute('accessibilityTraits');33console.log(isSelected);34const el = await driver.$('~Switch');35const isSelected = await el.getAttribute('accessibilityFrame');36console.log(isSelected);37const el = await driver.$('~Switch');38const isSelected = await el.getAttribute('accessibilityPath');

Full Screen

Using AI Code Generation

copy

Full Screen

1const el = await driver.$("~mySwitch");2const isSelected = await el.isSelected();3console.log(isSelected);4const el = await driver.$("~mySwitch");5const isSelected = await el.getAttribute("value");6console.log(isSelected);7const el = await driver.$("~mySwitch");8const isSelected = await el.getAttribute("selected");9console.log(isSelected);10const el = await driver.$("~mySwitch");11const isSelected = await el.getAttribute("enabled");12console.log(isSelected);13const el = await driver.$("~mySwitch");14const isSelected = await el.getAttribute("visible");15console.log(isSelected);16const el = await driver.$("~mySwitch");17const isSelected = await el.getAttribute("accessible");18console.log(isSelected);19const el = await driver.$("~mySwitch");20const isSelected = await el.getAttribute("accessibilityContainer");21console.log(isSelected);22const el = await driver.$("~mySwitch");23const isSelected = await el.getAttribute("accessibilityFrame");24console.log(isSelected);25const el = await driver.$("~mySwitch");26const isSelected = await el.getAttribute("accessibilityLabel");27console.log(isSelected);28const el = await driver.$("~mySwitch");29const isSelected = await el.getAttribute("accessibilityValue");30console.log(isSelected);31const el = await driver.$("~mySwitch");32const isSelected = await el.getAttribute("accessibilityLanguage");33console.log(isSelected);34const el = await driver.$("~mySwitch");35const isSelected = await el.getAttribute("accessibilityTraits");36console.log(isSelected);37const el = await driver.$("~my

Full Screen

Using AI Code Generation

copy

Full Screen

1var el = driver.findElement(By.name('switch'));2el.isSelected().then(function(isSelected){3 if(isSelected){4 console.log('Switch is ON');5 }6 else{7 console.log('Switch is OFF');8 }9});10var el = driver.findElement(By.name('switch'));11el.getAttribute('value').then(function(value){12 if(value == '1'){13 console.log('Switch is ON');14 }15 else{16 console.log('Switch is OFF');17 }18});19In the above code, we are using two different methods to get the value of the element. We are using el.isSelected() method to get the value of the element and using el.getAttribute('value') method to get the value of the element. Both the methods are working fine and returning the value

Full Screen

Using AI Code Generation

copy

Full Screen

1var el = driver.findElement(By.id("id_of_element"));2var elSelected = el.isSelected();3if (elSelected) {4 console.log("Element is selected");5} else {6 console.log("Element is not selected");7}8var el = driver.findElement(By.id("id_of_element"));9var elAttribute = el.getAttribute("selected");10if (elAttribute) {11 console.log("Element is selected");12} else {13 console.log("Element is not selected");14}15var el = driver.findElement(By.id("id_of_element"));16var elAttribute = el.getAttribute("value");17if (elAttribute) {18 console.log("Element is selected");19} else {20 console.log("Element is not selected");21}22var el = driver.findElement(By.id("id_of_element"));23var elAttribute = el.getAttribute("selected");24if (elAttribute) {25 console.log("Element is selected");26} else {27 console.log("Element is not selected");28}29var el = driver.findElement(By.id("id_of_element"));30var elAttribute = el.getAttribute("value");31if (elAttribute) {32 console.log("Element is selected");33} else {34 console.log("Element is not selected");35}36var el = driver.findElement(By.id("id_of_element"));37var elAttribute = el.getAttribute("selected");38if (elAttribute) {39 console.log("Element is selected");40} else {41 console.log("Element is not selected");42}43var el = driver.findElement(By.id("id_of_element"));44var elAttribute = el.getAttribute("value");45if (elAttribute) {46 console.log("Element is selected");47} else {48 console.log("Element is not selected");49}50var el = driver.findElement(By.id("id_of_element"));51var elAttribute = el.getAttribute("selected");52if (elAttribute) {53 console.log("Element is selected");54} else {55 console.log("Element is not selected");56}

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Test App', function() {2 it('should find an element', async function () {3 await driver.elementByAccessibilityId('Switch').isSelected().should.eventually.be.false;4 });5});6describe('Test App', function() {7 it('should find an element', async function () {8 await driver.elementByAccessibilityId('Switch').isSelected().should.eventually.be.false;9 });10});11describe('Test App', function() {12 it('should find an element', async function () {13 await driver.elementByAccessibilityId('Switch').isSelected().should.eventually.be.false;14 });15});16describe('Test App', function() {17 it('should find an element', async function () {18 await driver.elementByAccessibilityId('Switch').isSelected().should.eventually.be.false;19 });20});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wd = require('wd');2var driver = wd.promiseChainRemote('localhost', 4723);3var desiredCaps = {4};5 .init(desiredCaps)6 .elementByAccessibilityId('checkBox')7 .isSelected()8 .then(function(isSelected) {9 if (isSelected) {10 console.log('Checkbox is selected');11 } else {12 console.log('Checkbox is not selected');13 }14 })15 .fin(function() { return driver.quit(); })16 .done();

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Appium Xcuitest Driver automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Sign up Free
_

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful