Sign Up

Have an account? Sign In Now

Sign In

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask question.

Forgot Password?

Need An Account, Sign Up Here

You must login to ask question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Sign InSign Up

Softans

Softans Logo Softans Logo
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help

Ghulam Nabi

Ask Ghulam Nabi
1Follower
107Questions
Home/ Ghulam Nabi/Best Answers
  • About
  • Questions
  • Polls
  • Answers
  • Best Answers
  • Groups
  1. Asked: January 10, 2023

    JSONError: Unexpected token ‘<' at 1

    Ghulam Nabi
    Added an answer on January 10, 2023 at 12:46 pm

    Try this in postman: var jsonData = JSON.parse(responseBody); postman.setGlobalVariable("token1",(jsonData.results[0].token)); This is an example where you get the token from your JSON reponse and set it in a Global Variable. You can just change it to environment also if you like. More info about teRead more

    Try this in postman:

    var jsonData = JSON.parse(responseBody);
    postman.setGlobalVariable("token1",(jsonData.results[0].token));
    

    This is an example where you get the token from your JSON reponse and set it in a Global Variable. You can just change it to environment also if you like.

    More info about test scripts in postman: https://learning.getpostman.com/docs/postman/scripts/test_examples/

    See less
    • 0
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report
  2. Asked: January 4, 2023

    ‘newman’ is not recognized as an internal or external command

    Ghulam Nabi
    Added an answer on January 9, 2023 at 11:21 am

    Adding in the Path variable under Environment Variable solve the problem even if we don't add in NODE_PATH C:\Users\ yourusername \AppData\Roaming\npm After doing this reopen command prompt

    Adding in the Path variable under Environment Variable solve the problem even if we don’t add in NODE_PATH

    C:\Users\ yourusername \AppData\Roaming\npm

    After doing this reopen command prompt

    enter image description here

    enter image description here

    enter image description here

    See less
    • 0
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report
  3. Asked: December 23, 2022

    Cypress: Test if element does not exist

    Ghulam Nabi
    Added an answer on December 23, 2022 at 11:49 am

    Use .should('not.exist') to assert that an element does not exist in the DOM. Do not use not.visible assertion. It would falsely pass in < 6.0, but properly fail now: // for element that was removed from the DOM // assertions below pass in < 6.0, but properly fail in 6.0+ .should('not.be.visibRead more

    Use .should('not.exist') to assert that an element does not exist in the DOM.


    Do not use not.visible assertion. It would falsely pass in < 6.0, but properly fail now:

    // for element that was removed from the DOM
    // assertions below pass in < 6.0, but properly fail in 6.0+
    .should('not.be.visible')
    .should('not.contain', 'Text')
    

    Migration Docs here: Migrating-to-Cypress-6-0

    See less
    • 0
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report
  4. Asked: December 23, 2022

    Cypress get href attribute

    Ghulam Nabi
    Added an answer on December 23, 2022 at 11:39 am

    The code below should do what you're trying to achieve. There is also an entire recipe with suggestions on how to test links that open in new tabs. it('Advertise link should refer to Contact page', () => { cy.get('div.footer-nav > ul > li:nth-child(2) > a') .should('have.attr', 'href').aRead more

    The code below should do what you’re trying to achieve. There is also an entire recipe with suggestions on how to test links that open in new tabs.

    it('Advertise link should refer to Contact page', () => {
       cy.get('div.footer-nav > ul > li:nth-child(2) > a')
         .should('have.attr', 'href').and('include', 'contact')
         .then((href) => {
           cy.visit(href)
         })
    })
    

    I would also suggest reading through the Cypress document on the best ways to assign and work with variables: https://on.cypress.io/variables-and-aliases

    See less
    • 0
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report
  5. Asked: December 23, 2022

    Specify tsconfig.json location for Cypress

    Ghulam Nabi
    Added an answer on December 23, 2022 at 11:37 am

    While this is not the answer you would like to hear, tsconfig.json marks a directory as the root of a typescript project, just like the package.json marks a directory as the root of a node.js project. These files help tools like IDEs to understand your project. In my opinion you should only considerRead more

    While this is not the answer you would like to hear, tsconfig.json marks a directory as the root of a typescript project, just like the package.json marks a directory as the root of a node.js project. These files help tools like IDEs to understand your project.

    In my opinion you should only consider moving tsconfig.json when you start to put your package.json in some other folder as well.

    See also: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html

    See less
    • 0
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report
  6. Asked: December 23, 2022

    useParams returns ‘:1’, ‘:2’, ‘:3’ instead of ‘1’ , ‘2’, ‘3’

    Ghulam Nabi
    Added an answer on December 23, 2022 at 10:45 am

    I think the problem is here: http://localhost:3000/SuperHeroes/:2 The : in the route definition is not meant to be in the real route Use this address and check the id variable http://localhost:3000/SuperHeroes/2

    I think the problem is here:

    http://localhost:3000/SuperHeroes/:2

    The : in the route definition is not meant to be in the real route

    Use this address and check the id variable

    http://localhost:3000/SuperHeroes/2

    See less
    • 0
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report
  7. Asked: December 22, 2022

    Could not load file or assembly ‘System.ValueTuple’

    Ghulam Nabi
    Added an answer on December 22, 2022 at 12:07 pm

    I had to manually put System.ValueTuple.dll into C:\Windows\Microsoft.NET\assembly\GAC_MSIL\System.ValueTuple\v4.0_0.0.0.0__cc7b13ffcd2ddd51 in order for it to be automatically found in .Net 4.6.1 console app. No other recommendations helped.

    I had to manually put System.ValueTuple.dll into

    C:\Windows\Microsoft.NET\assembly\GAC_MSIL\System.ValueTuple\v4.0_0.0.0.0__cc7b13ffcd2ddd51

    in order for it to be automatically found in .Net 4.6.1 console app. No other recommendations helped.

    See less
    • 0
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report
  8. Asked: December 22, 2022

    Could not load file or assembly ‘System.Security.Cryptography.Xml

    Ghulam Nabi
    Added an answer on December 22, 2022 at 12:05 pm

    In addition to having a .NET Standard library you also have an application (like a console application) or perhaps a test project. The platform for the application determines what specific assembly referenced by your .NET Standard library to load. So your library references System.Security.CryptograRead more

    In addition to having a .NET Standard library you also have an application (like a console application) or perhaps a test project. The platform for the application determines what specific assembly referenced by your .NET Standard library to load.

    So your library references System.Security.Cryptography.Algorithms 4.3.0 however the actual version of the assembly to load for your platform may be 4.1.0 (that is the version you get on .NET Framework 4.6.1).

    So you need to inform your application to redirect the desired version (4.3.0) to the actual version for your runtime (4.1.0). You can do that in the app.config file. Remember that this file is used by the application and not the library. Adding an app.config file to your library will not make a difference.

    I tried to create a small project like the one you describe that in addition to a .NET Standard 1.4 library that references System.Security.Cryptography.Algorithms 4.3.0 has a NET Framework 4.62 console application and I had to include an app.config file with the following contents for this to work:

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
      <startup>
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2" />
      </startup>
    
      <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <dependentAssembly>
            <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-4.3.0.0" newVersion="4.1.1.0" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity name="System.Security.Cryptography.Algorithms" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-4.3.0.0" newVersion="4.1.0.0" />
          </dependentAssembly>
        </assemblyBinding>
      </runtime>
    </configuration>
    

    Anecdotally, this seems to be less of a problem if you switch to .NET Standard 2.0.

    See less
    • 0
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report
  9. Asked: December 22, 2022

    SpringBoot selecting the @Repository based on design pattern and configuration

    Ghulam Nabi
    Added an answer on December 22, 2022 at 12:04 pm

    Short answer: create a shared interface create multiple sub-class of this interface (one per storage) using different spring component names use Spring context to retrieve the right bean by name (instead of creating a custom factory) Now adding a new storage is only adding a new Repository classes wRead more

    Short answer:

    • create a shared interface
    • create multiple sub-class of this interface (one per storage) using different spring component names
    • use Spring context to retrieve the right bean by name (instead of creating a custom factory)

    Now adding a new storage is only adding a new Repository classes with a name

    Explanation: As mentioned in the other answer you first need to define a common interface as you can’t use the CrudRepository.save(...). In my example I reuse the same signature as the save method to avoid re-implementing it in the sub-classes of CrudRepository.

    public interface MyInterface<T> {
        <S extends T> S save(S entity);
    }
    

    Redis Repository:

    @Repository("redis") // Here is the name of the redis repo
    public class RedisRepository implements MyInterface<MyPojo>  {
        @Override
        public <S extends MyPojo> S save(S entity) {
            entity.setValue(entity.getValue() + " saved by redis");
            return entity;
        }
    }
    

    For the other CrudRepository no need to provide an implementation:

    @Repository("elastic") // Here is the name of the elastic repo
    public interface ElasticRepository  extends CrudRepository<MyPojo, String>, MyInterface<MyPojo> {
    }
    

    Now create the version three of your repository with the injection of SpringContext:

    @RestController
    public class ControllerVersionThree {
    
        private final ApplicationContext context;
    
        public ControllerVersionThree(ApplicationContext context) {
            this.context = context;
        }
    
        @PostMapping(path = "/save")
        public String save(@RequestBody MyRequest myRequest) {
            String whereToSave = myRequest.getWhereToSave();
            MyPojo myPojo = new MyPojo(UUID.randomUUID().toString(), myRequest.getValue());
            // Here, you should check the value of whereToSave to avoid some 'spring injection vulnerabilities'  
            MyInterface<MyPojo> repo = context.getBean(whereToSave, MyInterface.class);
            return repo.save(myPojo).toString();
        }
    }
    

    You can check that this is working with a test:

    import org.junit.jupiter.api.Test;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.boot.test.context.SpringBootTest;
    import org.springframework.boot.test.web.client.TestRestTemplate;
    import org.springframework.boot.test.web.server.LocalServerPort;
    import org.springframework.http.HttpEntity;
    
    import static org.junit.jupiter.api.Assertions.assertEquals;
    
    @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
    class ControllerVersionThreeTest {
        @LocalServerPort
        private int port;
    
        @Autowired
        private TestRestTemplate restTemplate;
    
        Dhaval Shah
        void testSaveByRedis() {
            // Given: here 'redis' is the name of th spring beans
            HttpEntity<MyRequest> request = new HttpEntity<>(new MyRequest("redis", "aValue"));
    
            // When
            String response = restTemplate.postForObject("http://localhost:" + port + "/save", request, String.class);
    
            // Then
            assertEquals("MyPojo{value='aValue saved by redis'}", response);
        }
    
    }
    See less
    • 0
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report
  10. Asked: December 22, 2022

    Set width of scrollbar in JS to 8px

    Ghulam Nabi
    Added an answer on December 22, 2022 at 11:52 am

    To make the fake scrollbar 8px wide, you can simply update the value of the scrollbarWidth variable to 8. Here's the updated code: menuButton.addEventListener('click', () => { // get width before hiding scrollbar let oldWidth = document.documentElement.clientWidth; // toggle CSS class that sets oRead more

    To make the fake scrollbar 8px wide, you can simply update the value of the scrollbarWidth variable to 8.

    Here’s the updated code:

    menuButton.addEventListener('click', () => {
    

    // get width before hiding scrollbar let oldWidth = document.documentElement.clientWidth;

    // toggle CSS class that sets overflow to hidden document.querySelector(“html”).classList.toggle(“no-scroll”);

    // get new width after hiding scrollbar let newWidth = document.documentElement.clientWidth;

    // set margin-right value equal to width of the scrollbar let scrollbarWidth = 8; document.body.style.marginRight = ${scrollbarWidth}px; });

    See less
    • 0
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report
1 2 3 4 5 6 … 9

Sidebar

Ask A Question
  • Popular
  • Answers
  • Ghulam Nabi

    Why are the British confused about us calling bread rolls ...

    • 5 Answers
  • Jerry

    Add file to native target programmatically via tuist/XcodeProj

    • 4 Answers
  • Ghulam Nabi

    Is this statement, “i see him last night” can be ...

    • 4 Answers
  • Ghulam Nabi
    Ghulam Nabi added an answer To add code coverage to a React project created without… February 3, 2023 at 7:01 am
  • Ghulam Nabi
    Ghulam Nabi added an answer You could try using the NetworkBoundResource architecture pattern. The idea… February 3, 2023 at 6:53 am
  • Ghulam Nabi
    Ghulam Nabi added an answer To programmatically set a package as the device owner, you… February 3, 2023 at 6:46 am

Trending Tags

android c++ cypress flutter java javascript python selenium testng webdriver

Top Members

Robert

Robert

  • 3 Questions
  • 1k Points
Luci

Luci

  • 5 Questions
  • 1k Points
Kevin O Brien

Kevin O Brien

  • 2 Questions
  • 1k Points

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help

Footer

Softans

Softans is a social questions & Answers Engine which will help you establish your community and connect with other people.

About Us

  • Blog
  • Jobs
  • About Us
  • Meet The Team
  • Contact Us

Legal Stuff

Help

Follow

© 2021 Softans. All Rights Reserved
With Love by Softans.