Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

selenium selectors not working in 7.0 preScript #2060

Closed
mscrivo opened this issue May 28, 2018 · 9 comments
Closed

selenium selectors not working in 7.0 preScript #2060

mscrivo opened this issue May 28, 2018 · 9 comments

Comments

@mscrivo
Copy link

mscrivo commented May 28, 2018

Just upgraded to 7.0 (using the docker image) and discovered our pre scripts stopped working. It seems that the selenium selectors are not working any more. I am using using essentially an exact copy of https://www.sitespeed.io/documentation/sitespeed.io/prepostscript/ and it's throwing errors like this:

[2018-05-28 20:55:15] ERROR: NoSuchElementError: no such element: Unable to locate element: {"method":"css selector","selector":"*[id="loginPageEmail"]"}

Dropping back down to 6.5.4 and it works perfectly fine.

@soulgalore
Copy link
Member

Hi @mscrivo for Firefox and Chrome or one of them? One change is that we have changed Selenium pageLoadStrategy to none, meaning the driver get hold of the page direct after the navigation instead of waiting for page load, I've missed that in the login script.

Either in your script you can add a wait/test for an element on the page (that should have been there from the beginning) so that you know the page is loaded (I'll update the example in a couple of days) or you can run with the old page load strategy. --browsertime.pageLoadStrategy normal

Best
Peter

@mscrivo
Copy link
Author

mscrivo commented May 29, 2018

Thank you @soulgalore that worked! I'm running into another issue now ffmpeg, will open a new issue for that one.

@mscrivo mscrivo closed this as completed May 29, 2018
@calebcassel
Copy link

I had this issue, and as of today it's working again with the latest docker image. 👍

@sureshkrishnaselvam
Copy link

Hi @soulgalore I am using sitespeed.io 7.0 and executing prescripts, but I am getting NoSuchElementError:
Here is the error log,

ERROR: NoSuchElementError: no such element: Unable to locate element: {"method":"xpath","selector":"//div[@id='product-row-0']/div/div[1]/div/div/div/div/div[2]/div[7]/button[2]"}
(Session info: chrome=66.0.3359.33)
(Driver info: chromedriver=2.38.552522 (437e6fbedfa8762dec75e2c5b3ddb86763dc9dcb),platform=Linux 4.13.0-1011-azure x86_64)
(Session info: chrome=66.0.3359.33)
(Driver info: chromedriver=2.38.552522 (437e6fbedfa8762dec75e2c5b3ddb86763dc9dcb),platform=Linux 4.13.0-1011-azure x86_64)
at Object.checkLegacyResponse (/usr/src/app/node_modules/selenium-webdriver/lib/error.js:546:15)
at parseHttpResponse (/usr/src/app/node_modules/selenium-webdriver/lib/http.js:509:13)
at doSend.then.response (/usr/src/app/node_modules/selenium-webdriver/lib/http.js:441:30)
at
at process.tickCallback (internal/process/next_tick.js:188:7)
From: Task: WebDriver.findElement(By(xpath, //div[@id='product-row-0']/div/div[1]/div/div/div/div/div[2]/div[7]/button[2]))
at Driver.schedule (/usr/src/app/node_modules/selenium-webdriver/lib/webdriver.js:807:17)
at Driver.findElement (/usr/src/app/node_modules/selenium-webdriver/lib/webdriver.js:1014:17)
at driver.get.then (/home/jenkins/workspace/Login_VPD/wag-vpd-ui/test/performance/Sitespeed/cartflow.js:16:34)
at ManagedPromise.invokeCallback
(/usr/src/app/node_modules/selenium-webdriver/lib/promise.js:1376:14)
at TaskQueue.execute_ (/usr/src/app/node_modules/selenium-webdriver/lib/promise.js:3084:14)
at TaskQueue.executeNext_ (/usr/src/app/node_modules/selenium-webdriver/lib/promise.js:3067:27)
at asyncRun (/usr/src/app/node_modules/selenium-webdriver/lib/promise.js:2927:27)
at /usr/src/app/node_modules/selenium-webdriver/lib/promise.js:668:7
at
at process.tickCallback (internal/process/next_tick.js:188:7)
From: Task: WebElement.click()
at Driver.schedule (/usr/src/app/node_modules/selenium-webdriver/lib/webdriver.js:807:17)
at WebElementPromise.schedule
(/usr/src/app/node_modules/selenium-webdriver/lib/webdriver.js:2010:25)
at WebElementPromise.click (/usr/src/app/node_modules/selenium-webdriver/lib/webdriver.js:2092:17)
at driver.get.then (/home/jenkins/workspace/Login_VPD/wag-vpd-ui/test/performance/Sitespeed/cartflow.js:17:21)
at ManagedPromise.invokeCallback_ (/usr/src/app/node_modules/selenium-webdriver/lib/promise.js:1376:14)
at TaskQueue.execute_ (/usr/src/app/node_modules/selenium-webdriver/lib/promise.js:3084:14)
at TaskQueue.executeNext_ (/usr/src/app/node_modules/selenium-webdriver/lib/promise.js:3067:27)
at asyncRun (/usr/src/app/node_modules/selenium-webdriver/lib/promise.js:2927:27)
at /usr/src/app/node_modules/selenium-webdriver/lib/promise.js:668:7
at
at process._tickCallback (internal/process/next_tick.js:188:7)

@sureshkrishnaselvam
Copy link

Can you please suggest me to resolve the issue.

@soulgalore
Copy link
Member

Hi @sureshkrishnaselvam do you run latest 7? looks like your Selenium code isn't working, like the button you try to find isn't there.

NoSuchElementError: no such element: Unable to locate element:

Can you verify that the Selenium xpath code works outside of sitespeed.io? You can make sure your code catch these errors when you test and then you can also use the log to get some more info from your runs, like fetching different dom objects in Seleneium and verify that you catch those that you want.

Best
Peter

@sureshkrishnaselvam
Copy link

Hi @soulgalore thanks for you comments, I tried in both 7.1.3 and 7.0.0 versions using docker. used different dom objects changed id, name, used xpath in different ways. Its works in selenium scripts but when we run through sitespeed.io its getting error.

Here is the script,
module.exports = {
run(context) {
return context.runWithDriver((driver) => {
return driver.get('https://www.XXXXX.com/login.jsp')
.then(() => {

      var webdriver = context.webdriver;
      var until = webdriver.until;
      var By = webdriver.By;

      var userName = 'XXXXXXXX';
      var passWord = 'XXXXXXXX';
      var usertext = driver.findElement(webdriver.By.xpath("//input[@id='userName-phoneNo']"));
      usertext.sendKeys(userName);
      var continueButton = driver.findElement(webdriver.By.xpath("//button[@id='continueBtn']"));
      continueButton.click();
      var passwordtext = driver.findElement(webdriver.By.xpath("//input[@id='password']"));
      passwordtext.sendKeys(passWord);
      var signinButton = driver.findElement(webdriver.By.id('passwordtabSignIn'));
      signinButton.click();
      // we wait for something on the page that verifies that we are logged in
      return driver.wait(until.elementLocated(webdriver.By.id('ntt-placeholder')), 10000);
    });
})

}
};

docker run --shm-size=1g --rm -v /Users/sureshkrishna_s/Sitespeed_Volume:/sitespeed.io sitespeedio/sitespeed.io:7.1.13 --preScript /sitespeed.io/login.js https://www.XXXXXXX.com/store/checkout/cart.jsp

Error Log:

ERROR: WebDriverError: unknown error: Element Continue is not clickable at point (682, 290). Other element would receive the click:


(Session info: chrome=67.0.3396.99)
(Driver info: chromedriver=2.40.565383 (76257d1ab79276b2d53ee976b2c3e3b9f335cde7),platform=Linux 4.9.87-linuxkit-aufs x86_64)
(Session info: chrome=67.0.3396.99)
(Driver info: chromedriver=2.40.565383 (76257d1ab79276b2d53ee976b2c3e3b9f335cde7),platform=Linux 4.9.87-linuxkit-aufs x86_64)
at Object.checkLegacyResponse (/usr/src/app/node_modules/selenium-webdriver/lib/error.js:546:15)
at parseHttpResponse (/usr/src/app/node_modules/selenium-webdriver/lib/http.js:509:13)
at doSend.then.response (/usr/src/app/node_modules/selenium-webdriver/lib/http.js:441:30)
at
at process.tickCallback (internal/process/next_tick.js:188:7)
From: Task: WebElement.click()
at Driver.schedule (/usr/src/app/node_modules/selenium-webdriver/lib/webdriver.js:807:17)
at WebElementPromise.schedule
(/usr/src/app/node_modules/selenium-webdriver/lib/webdriver.js:2010:25)
at WebElementPromise.click (/usr/src/app/node_modules/selenium-webdriver/lib/webdriver.js:2092:17)
at driver.get.then (/sitespeed.io/login.js:30:26)
at ManagedPromise.invokeCallback_ (/usr/src/app/node_modules/selenium-webdriver/lib/promise.js:1376:14)
at TaskQueue.execute_ (/usr/src/app/node_modules/selenium-webdriver/lib/promise.js:3084:14)
at TaskQueue.executeNext_ (/usr/src/app/node_modules/selenium-webdriver/lib/promise.js:3067:27)
at asyncRun (/usr/src/app/node_modules/selenium-webdriver/lib/promise.js:2927:27)
at /usr/src/app/node_modules/selenium-webdriver/lib/promise.js:668:7
at
at process._tickCallback (internal/process/next_tick.js:188:7)

@soulgalore
Copy link
Member

You can add --browsertime.videoParams.keepOriginalVideo to keep the video from both pre and post scripts, that way you can see what's actually is happening, or run with npm on your local desktop and check the browser and see that you really pick the right element.

In your script: continueButton.click() does that load a new page or what happens? If so then you need to wait for the page to load.

Best
Peter

@Nuoky
Copy link

Nuoky commented Jul 2, 2018

SeleniumHQ/selenium#2969 (comment)
Try use promise

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants