ImportError: cannot import name 'ugettext' from 'django.utils.translation' - authentication

from rest_framework_jwt.views import obtain_jwt_token,refresh_jwt_token,verify_jwt_token
path('auth-jwt/', obtain_jwt_token),
path('auth-jwt-refresh/',refresh_jwt_token),
path('auth-jwt-verify/', verify_jwt_token),
getting error after addding the above urls ,I have installed jwt using this pip install djangorestframework -jwt
I want to implement JWT Authentication

from .serializers import (
File "*\lib\site-packages\rest_framework_jwt\serializers.py", line 7, in
from django.utils.translation import ugettext as _
ImportError: cannot import name 'ugettext' from 'django.utils.translation' (c:\users\dell\downloads\djangoEnvs\djangoEnv\lib\site-packages\django\utils\translation_init_.py)
There are two ways of resolving above issues:
Way 1: (Not recommended Approach)
Steps:
Open the last file in traceback (<path showing in your IDE>\lib\site-packages\rest_framework_jwt\serializers.py) :
In this file, replace ugettext with --> gettext
Enjoy coding!!!! :)
before replace:
from django.utils.translation import ugettext as _
after replace:
from django.utils.translation import gettext as _
Way2 : (Recommended Approach)
Steps are:
Open settings.py (project folder)
On the top of settings.py type below imports
import django
from django.utils.translation import gettext
django.utils.translation.ugettext = gettext
Enjoy Coding !!!!! :)

Related

Didn't work driver.find_elements_by_class_name() and driver.find_elements() functions

I have tried to retrieve some data from url page via Selenium, but after running function driver.find_element_by_class_name() I have obtained error message:
'WebDriver' object has no attribute 'find_element_by_class_name'
Maybe this function has been deprecated in new module updates, please give me a hint where to find documentation for new function instead of deprecated.
This is my code:
import pandas as pd
import time
import selenium
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from webdriver_manager.chrome import ChromeDriverManager
import seaborn as sns
import os
import logging
######
PATH = 'C:/Program Files/chromedriver/chromedriver.exe'
options = Options()
driver = webdriver.Chrome(service =
Service(PATH))
page_url = "https://witcher.fandom.com/wiki/Category:Characters_in_the_stories"
driver.get(page_url)
book_categories = driver.find_elements_by_class_name('category-page__member-link')
AttributeError: 'WebDriver' object has no attribute 'find_elements_by_class_name'
------------
book_categories = driver.find_elements(By = 'class_name','category-page__member-link')
SyntaxError: positional argument follows keyword argument
I use chromedriver version 109.0.5414.74. Chrome version 109.0.5414.75.
Also I tried to use this code:
driver.find_elements(By.NAME, 'category-page__member-link),
but it also led to error:
NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":"[name="category-page__member-link"]"}.
Please, help me to find out reason of this error and how to resolve it.
Your locator is correct, but your locator type is wrong. 'category-page__member-link' is the value of class attribute not name, so you have to mention like:
driver.find_element(By.CLASS_NAME, "category-page__member-link")
or
driver.find_element(By.CSS_SELECTOR, ".category-page__member-link")

TinyMCE ERR_ABORTED 404 (Not Found) skins (vue)

I'm facing the console error issue with tinymce on vue.js. It works correctly both localhost and server hovewer editor throws me error on server (doesn't throw error on localhost).
console errors
Here is my import section
[I've tried import files both dynamically and statically, hovewer errors continue to exist]
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js">
import Editor from "#tinymce/tinymce-vue";
import "tinymce/tinymce";
// Theme
import "../../../../../../node_modules/tinymce/themes/silver/theme";
// Skins
import "../../../../../../node_modules/tinymce/skins/ui/oxide/skin.min.css";
import "../../../../../../node_modules/tinymce/skins/ui/oxide/content.min.css";
import "../../../../../../node_modules/tinymce/skins/content/default/content.min.css";
// Plugins
import "../../../../../../node_modules/tinymce/plugins/fullscreen";
import "../../../../../../node_modules/tinymce/plugins/paste";
import "../../../../../../node_modules/tinymce/plugins/autoresize";
import "../../../../../../node_modules/tinymce/icons/default";
</script>
I've solved my issue with writing :init="{content_css: false, skin: false}" property to editor tag

karate.log file is not getting generated

I have placed the logback-test.xml in classpath
karate.log is not getting generated, I have seen there is a file called main.log that gets generated sometime
Here is the project structure
Here is the runner file
package com.org.KarateLearning;
import com.intuit.karate.KarateOptions;
import com.intuit.karate.Results;
import com.intuit.karate.Runner;
import com.intuit.karate.junit4.Karate;
import org.junit.Test;
import org.junit.runner.RunWith;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.Map;
import java.util.Properties;
import static org.junit.Assert.assertTrue;
public class ParallelTestRunner {
#Test
public void parallel() {
Results res = Runner.path("classpath:features").tags("~#ignore").parallel(5);
assertTrue(res.getErrorMessages(),res.getFailCount()==0);
}}
I have tried placing logback-test.xml in resources and com.org.KarateLearning but karate.log is not getting genearted
Deleted the existing file ( logback-test.xml ) and created a new one from below path under src/test/java
https://github.com/intuit/karate/blob/master/karate-demo/src/test/java/logback-test.xml
Now file is getting generated in target folder
In between it was getting generated outside of target folder. Now its getting generated at correct location inside target folder.
Also note even after deleting the logback-test.xml log was getting generated. (not sure about the reason for it)
Now all works well

Click button doesn't work - Katalon Studio

I am new to Katalon studio and am trying to run my test case but it's always filed as it says:
Error:
Test Cases/Logging in FAILED because (of) (Stack trace: com.kms.katalon.core.exception.StepFailedException: Unable to >click on object 'Object Repository/Page_BaseLine - test/input_Przypomnienie o fakturze' (Root cause: com.kms.katalon.core.webui.exception.WebElementNotFoundException: Web element with id: 'Object Repository/Page_BaseLine - test/input_Przypomnienie o fakturze' located by 'By.xpath: >//input[#id='SubmitButton']' not found)
I tried to do it manually but everytime the same problem appears, what shall I do then?
Here is my source code:
import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint
import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import com.kms.katalon.core.checkpoint.Checkpoint as Checkpoint
import com.kms.katalon.core.checkpoint.CheckpointFactory as CheckpointFactory
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as MobileBuiltInKeywords
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile
import com.kms.katalon.core.model.FailureHandling as FailureHandling
import com.kms.katalon.core.testcase.TestCase as TestCase
import com.kms.katalon.core.testcase.TestCaseFactory as TestCaseFactory
import com.kms.katalon.core.testdata.TestData as TestData
import com.kms.katalon.core.testdata.TestDataFactory as TestDataFactory
import com.kms.katalon.core.testobject.ObjectRepository as ObjectRepository
import com.kms.katalon.core.testobject.TestObject as TestObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WSBuiltInKeywords
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUiBuiltInKeywords
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import internal.GlobalVariable as GlobalVariable
import org.openqa.selenium.Keys as Keys
import com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords as CucumberKW
WebUI.openBrowser('')
def plik = new File('Config.txt')
def lines = plik.readLines()
WebUI.navigateToUrl(lines[0])
WebUI.setText(findTestObject('Object Repository/Page_Demo version BaseLine/input_Login form_LoginTextBox'), lines[1])
WebUI.setText(findTestObject('Object Repository/Page_Demo version BaseLine/input_Login form_PasswordTextB'), lines[2])
WebUI.click(findTestObject('Object Repository/Page_Demo version BaseLine/input_remember me_LoginButton'))
WebUI.click(findTestObject('Page_BaseLine - test/a_Kontrahenci'))
WebUI.click(findTestObject('Page_BaseLine - test/a_Dodaj Kontrahenta'))
WebUI.setText(findTestObject('own/Page_BaseLine - test/input_Nazwa skrcona_ShortNameT'), 'greg12')
WebUI.setText(findTestObject('own/Page_BaseLine - test/textarea_'), 'Grzegorz Spytek12')
WebUI.click(findTestObject('Page_BaseLine - test/input_Przypomnienie o fakturze'))
WebUI.click(findTestObject('Page_BaseLine - test/input_Opis_CloseButton'))
Thanks for help.
The xpath seems not correct. Could you try removing the '>'?
>//input[#id='SubmitButton']'

Jest does not resolve lodash imports

I'm writing a web component using StencilJS. One of the helper classes (ArrayHelper.ts) which is imported by my component has these import at the top:
import transform from 'lodash/transform';
import isEmpty from 'lodash/isEmpty';
import isEqual from 'lodash/isEqual';
import isObject from 'lodash/isObject';
this all works fine when compiling and serving locally. However, when writing some unit tests and executing them using jest, jest can't resolve these imports properly:
TypeError: isObject_1.default is not a function at Function.Object.
<anonymous>.ArrayHelper.toArray (/mycomponent/ArrayHelper.ts:15:35)
When I change the imports in ArrayHelper.ts to
import { isEmpty, isEqual, isObject, transform } from 'lodash';
then Jest will succesfully run the tests without problems but then the TS compilation by stencilJS doesn't work any more:
Missing Export: mycomponents/ArrayHelper.js:5:27
'isObject' is not exported by node_modules/lodash/lodash.js
Any ideas how to get these imports right for both situations?
Try import lodash like this
import * as _ from "lodash";
Try adding this to your stencil.config.js:
nodeResolve: {
browser: true
}
This is happening because lodash is not available where Jest is running your tests. Is it an experimental browser technology.
Refer - Link1 Link2
import * as transform from 'lodash/transform';
import * as isEmpty from 'lodash/isEmpty';
import * as isEqual from 'lodash/isEqual';
import * as isObject from 'lodash/isObject';