Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Porting pure webdriver based test to CodeceptJs test adds URL encoding

Open
#3,072 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
32/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
javascript, node.js
Domain
testing-qa

Research direction

Start with the I.amOnPage call in the supplied test and the WebDriver helper settings in the configuration; compare its navigation behavior with the Selenium driver.get example. Trace how the URL fragment is passed and encoded, then add a regression test using the reported URL. Done means CodeceptJS preserves the URL behavior expected by the original webdriver test.

Written by the indexing model from the issue text.

Description

What are you trying to achieve?

call this url by selenium via webdriver:

https://host.docker.internal:8000/payroll/#company/1-250|project|projectViewState/{%22type%22:%22event%22,%22date_range%22:%221%20WEEK%22,%22eventid%22:1,%22eventdb%22:250,%22regularcheckin%22:true}|listViewOpen/2-250

What do you get instead?

but this got sent instead (|, { and } are got encoded):

https://host.docker.internal:8000/payroll/#company/1-250%7Cproject%7CprojectViewState/%7B%22type%22:%22event%22,%22date_range%22:%221%20WEEK%22,%22eventid%22:1,%22eventdb%22:250,%22regularcheckin%22:true%7D%7ClistViewOpen/2-250

Provide test source code if related

Scenario('change the company', async ({ I }) => {
    I.amOnPage('https://host.docker.internal:8000/payroll/#company/1-250|project|projectViewState/{%22type%22:%22event%22,%22date_range%22:%221%20WEEK%22,%22eventid%22:1,%22eventdb%22:250,%22regularcheckin%22:true}|listViewOpen/2-250');
    let url = await I.grabCurrentUrl();
    console.log(`Current URL is [${url}]`);
})```

the original test works well 

````js
// Generated by Selenium IDE
const { Builder, By, Key, until} = require('selenium-webdriver')
const  chrome  = require('selenium-webdriver/chrome')
const  logging  = require('selenium-webdriver/lib/logging')
const assert = require('assert')
const BASEURL = 'https://host.docker.internal:8000/payroll/';

describe('Payroll', function() {
  this.timeout(30000)
  let driver
  let options
  beforeEach(async function() {
    builder = new Builder();
    options = (new chrome.Options()).setAcceptInsecureCerts(true);
    prefs = new logging.Preferences();
    prefs.setLevel(logging.Type.BROWSER, logging.Level.ALL);
    options.setLoggingPrefs(prefs);
    driver = await builder.forBrowser('chrome').usingServer('http://localhost:4444/wd/hub').setChromeOptions(options).build()
    vars = {}
  })
  afterEach(async function() {
    //await driver.manage().logs().get(logging.Type.BROWSER).then((logs) => console.log(logs))
    await driver.takeScreenshot().then((image) => require('fs').writeFileSync('captured_image_3.png', image, 'base64'));   
    await driver.quit();
  })

  async function openBrowser(driver, url) {
    await driver.get(BASEURL + url);
    let username = await driver.wait(until.elementLocated(By.id("login-username-inputEl")));
    username.sendKeys("arthur");
    let password = await driver.wait(until.elementLocated(By.id("login-password-inputEl")));
    password.sendKeys("hwzsyx5h$");
    let loginButton =  await driver.wait(until.elementLocated(By.id("login-button")));
    loginButton.click();
    await driver.manage().window().setRect(1924, 768) 
  }

  it('open and save the contract editor', async function() {
  await openBrowser(driver, "#company/1-250|project|projectViewState/{%22type%22:%22event%22,%22date_range%22:%221%20WEEK%22,%22eventid%22:1,%22eventdb%22:250,%22regularcheckin%22:true}|listViewOpen/2-250")
  await driver.wait(until.elementLocated(By.id("firstname-inputEl")), NaN)
  await driver.findElement(By.id("open-editor")).click()
  await driver.findElement(By.id("overtimeunitAsMinutes-inputEl")).click()
  await driver.findElement(By.id("overtimeunitAsMinutes-inputEl")).sendKeys("30")
  await driver.findElement(By.id("save-editor")).click()
})

})

Details
  • CodeceptJS version: 3.13
  • NodeJS Version:16.9.1
  • Operating System: WSL Ubuntu 20
  • webdriverio: 6.12.1
  • Configuration file: ?
exports.config = {
  tests: './tests/acceptance/codeceptjs/*.co.js',
  output: './output',
  helpers: {
    WebDriver: {
      url: 'https://localhost',
      browser: 'chrome',
      host: '127.0.0.1',
      port: 4444,
      restart: true,
      windowSize: '1920x1680',
      smartWait: 5000,
      desiredCapabilities: {
        chromeOptions: {
          args: [ /*"--headless",*/ "--disable-gpu", "--no-sandbox", "--ignore-certificate-errors" ]
        }
      }
    }
  },
  include: {
    I: './steps_file.js'
  },
  bootstrap: null,
  mocha: {},
  name: 'payroll',
  plugins: {
    pauseOnFail: {},
    retryFailedStep: {
      enabled: true
    },
    tryTo: {
      enabled: true
    },
    screenshotOnFail: {
      enabled: true
    }
  }
}```
Dominant language
JavaScript
Stars
4.2k
Forks
756
Avg merge
2d 9h
Merged PRs (30d)
16

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from codeceptjs/CodeceptJS

All issues in codeceptjs/CodeceptJS

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.