Search code examples
javascriptwebdriver

webdriver.io no such element


I'm getting no such element error over and over again. I'm working with error more than 7 hours. Dom has the id. But i get error 'no such element'. Here's my code:

describe("Amazon", () => {
  it("Search amazon", () => {
    browser.url("https://www.amazon.com.tr/");
    let searchField = $("#twotabsearchtextbox");
    const submit = $("#nav-search-submit-button");
    searchField.setValue("mouse");
    submit.click();
  });
});

And here's the log:

Screenshot of the log

Thanks everyone


Solution

  • This probably means that you are not working in the correct context. You should check if the element is located inside an iframe.

    If it's the case, you will need to switch to this iframe context before being able to query the element. You can do so using the WebDriver API 'switch to frame' (W3C webdriver spec) which is available through the webdriver.io API switchToFrame.