How to ignore extra whitespaces after switching to headless chrome
Recently I switched my cucumber tests from capybara-webkit to headless chrome. Now many features fail with
expected to find text "commented by J. Smitch" in "commented by[two spaces there]J. Smith"
Is there a way to tell Capybara to ignore extra whitespaces?
Or I need to add whitespaces in my step definitions to make the failing tests green?
UPDATE 1
I have
spaces in my markup which are not normalized like this
<div>
commented by
<span>J. Smith</span>
</div>
capybara google-chrome-headless
add a comment |
Recently I switched my cucumber tests from capybara-webkit to headless chrome. Now many features fail with
expected to find text "commented by J. Smitch" in "commented by[two spaces there]J. Smith"
Is there a way to tell Capybara to ignore extra whitespaces?
Or I need to add whitespaces in my step definitions to make the failing tests green?
UPDATE 1
I have
spaces in my markup which are not normalized like this
<div>
commented by
<span>J. Smith</span>
</div>
capybara google-chrome-headless
add a comment |
Recently I switched my cucumber tests from capybara-webkit to headless chrome. Now many features fail with
expected to find text "commented by J. Smitch" in "commented by[two spaces there]J. Smith"
Is there a way to tell Capybara to ignore extra whitespaces?
Or I need to add whitespaces in my step definitions to make the failing tests green?
UPDATE 1
I have
spaces in my markup which are not normalized like this
<div>
commented by
<span>J. Smith</span>
</div>
capybara google-chrome-headless
Recently I switched my cucumber tests from capybara-webkit to headless chrome. Now many features fail with
expected to find text "commented by J. Smitch" in "commented by[two spaces there]J. Smith"
Is there a way to tell Capybara to ignore extra whitespaces?
Or I need to add whitespaces in my step definitions to make the failing tests green?
UPDATE 1
I have
spaces in my markup which are not normalized like this
<div>
commented by
<span>J. Smith</span>
</div>
capybara google-chrome-headless
capybara google-chrome-headless
edited Nov 20 at 13:35
asked Nov 20 at 12:06
Hirurg103
959714
959714
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
I'm guessing that at the same time you switched from capybara-webkit to selenium with headless chrome you also switched from Capybara 2.x to 3.x. One of the breaking changes in Capybara 3.x is that it attempts to return whitespace more as the user would actually see it. That means that if you have characters in your markup they don't get collapsed with surrounding spaces since the browser doesn't do that. You can use the normalize_ws
option to get back results more like 2.x
expect(page).to have_text('blah blah', normalize_ws: true)
however if you're going to the trouble of adding characters to your page you should probably be checking that the text is displaying with the multiple spaces as you intended.
No, I am not upgrading from capybara 2 to 3. I just upgraded from capybara 3.5 to 3.11. But I didn't have problem with normalizing whitespaces with capybara-webkit (seems capybara-webkit uses the old strategy with normalizing whitespaces as I had to silence deprecation warnings with normalizing whitespaces). Yes, you are right, capybara 3 doesn't remove browser whitespaces github.com/teamcapybara/capybara/issues/1353
– Hirurg103
Nov 21 at 7:47
@Hirurg103 If you were getting deprecation notices around whitespace with capybara-webkit then you weren't using the latest capybara-webkit which was actually compatible with Capybara 3.x - anyway you're going to be much better with Chrome since the JS/CSS support is up to date
– Thomas Walpole
Nov 21 at 8:12
Before moving to headless chrome I was using capybarav3.5.0
and capybara-webkitv1.15.0
– Hirurg103
Nov 21 at 9:30
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53392662%2fhow-to-ignore-extra-whitespaces-after-switching-to-headless-chrome%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I'm guessing that at the same time you switched from capybara-webkit to selenium with headless chrome you also switched from Capybara 2.x to 3.x. One of the breaking changes in Capybara 3.x is that it attempts to return whitespace more as the user would actually see it. That means that if you have characters in your markup they don't get collapsed with surrounding spaces since the browser doesn't do that. You can use the normalize_ws
option to get back results more like 2.x
expect(page).to have_text('blah blah', normalize_ws: true)
however if you're going to the trouble of adding characters to your page you should probably be checking that the text is displaying with the multiple spaces as you intended.
No, I am not upgrading from capybara 2 to 3. I just upgraded from capybara 3.5 to 3.11. But I didn't have problem with normalizing whitespaces with capybara-webkit (seems capybara-webkit uses the old strategy with normalizing whitespaces as I had to silence deprecation warnings with normalizing whitespaces). Yes, you are right, capybara 3 doesn't remove browser whitespaces github.com/teamcapybara/capybara/issues/1353
– Hirurg103
Nov 21 at 7:47
@Hirurg103 If you were getting deprecation notices around whitespace with capybara-webkit then you weren't using the latest capybara-webkit which was actually compatible with Capybara 3.x - anyway you're going to be much better with Chrome since the JS/CSS support is up to date
– Thomas Walpole
Nov 21 at 8:12
Before moving to headless chrome I was using capybarav3.5.0
and capybara-webkitv1.15.0
– Hirurg103
Nov 21 at 9:30
add a comment |
I'm guessing that at the same time you switched from capybara-webkit to selenium with headless chrome you also switched from Capybara 2.x to 3.x. One of the breaking changes in Capybara 3.x is that it attempts to return whitespace more as the user would actually see it. That means that if you have characters in your markup they don't get collapsed with surrounding spaces since the browser doesn't do that. You can use the normalize_ws
option to get back results more like 2.x
expect(page).to have_text('blah blah', normalize_ws: true)
however if you're going to the trouble of adding characters to your page you should probably be checking that the text is displaying with the multiple spaces as you intended.
No, I am not upgrading from capybara 2 to 3. I just upgraded from capybara 3.5 to 3.11. But I didn't have problem with normalizing whitespaces with capybara-webkit (seems capybara-webkit uses the old strategy with normalizing whitespaces as I had to silence deprecation warnings with normalizing whitespaces). Yes, you are right, capybara 3 doesn't remove browser whitespaces github.com/teamcapybara/capybara/issues/1353
– Hirurg103
Nov 21 at 7:47
@Hirurg103 If you were getting deprecation notices around whitespace with capybara-webkit then you weren't using the latest capybara-webkit which was actually compatible with Capybara 3.x - anyway you're going to be much better with Chrome since the JS/CSS support is up to date
– Thomas Walpole
Nov 21 at 8:12
Before moving to headless chrome I was using capybarav3.5.0
and capybara-webkitv1.15.0
– Hirurg103
Nov 21 at 9:30
add a comment |
I'm guessing that at the same time you switched from capybara-webkit to selenium with headless chrome you also switched from Capybara 2.x to 3.x. One of the breaking changes in Capybara 3.x is that it attempts to return whitespace more as the user would actually see it. That means that if you have characters in your markup they don't get collapsed with surrounding spaces since the browser doesn't do that. You can use the normalize_ws
option to get back results more like 2.x
expect(page).to have_text('blah blah', normalize_ws: true)
however if you're going to the trouble of adding characters to your page you should probably be checking that the text is displaying with the multiple spaces as you intended.
I'm guessing that at the same time you switched from capybara-webkit to selenium with headless chrome you also switched from Capybara 2.x to 3.x. One of the breaking changes in Capybara 3.x is that it attempts to return whitespace more as the user would actually see it. That means that if you have characters in your markup they don't get collapsed with surrounding spaces since the browser doesn't do that. You can use the normalize_ws
option to get back results more like 2.x
expect(page).to have_text('blah blah', normalize_ws: true)
however if you're going to the trouble of adding characters to your page you should probably be checking that the text is displaying with the multiple spaces as you intended.
answered Nov 20 at 16:49
Thomas Walpole
29.8k32647
29.8k32647
No, I am not upgrading from capybara 2 to 3. I just upgraded from capybara 3.5 to 3.11. But I didn't have problem with normalizing whitespaces with capybara-webkit (seems capybara-webkit uses the old strategy with normalizing whitespaces as I had to silence deprecation warnings with normalizing whitespaces). Yes, you are right, capybara 3 doesn't remove browser whitespaces github.com/teamcapybara/capybara/issues/1353
– Hirurg103
Nov 21 at 7:47
@Hirurg103 If you were getting deprecation notices around whitespace with capybara-webkit then you weren't using the latest capybara-webkit which was actually compatible with Capybara 3.x - anyway you're going to be much better with Chrome since the JS/CSS support is up to date
– Thomas Walpole
Nov 21 at 8:12
Before moving to headless chrome I was using capybarav3.5.0
and capybara-webkitv1.15.0
– Hirurg103
Nov 21 at 9:30
add a comment |
No, I am not upgrading from capybara 2 to 3. I just upgraded from capybara 3.5 to 3.11. But I didn't have problem with normalizing whitespaces with capybara-webkit (seems capybara-webkit uses the old strategy with normalizing whitespaces as I had to silence deprecation warnings with normalizing whitespaces). Yes, you are right, capybara 3 doesn't remove browser whitespaces github.com/teamcapybara/capybara/issues/1353
– Hirurg103
Nov 21 at 7:47
@Hirurg103 If you were getting deprecation notices around whitespace with capybara-webkit then you weren't using the latest capybara-webkit which was actually compatible with Capybara 3.x - anyway you're going to be much better with Chrome since the JS/CSS support is up to date
– Thomas Walpole
Nov 21 at 8:12
Before moving to headless chrome I was using capybarav3.5.0
and capybara-webkitv1.15.0
– Hirurg103
Nov 21 at 9:30
No, I am not upgrading from capybara 2 to 3. I just upgraded from capybara 3.5 to 3.11. But I didn't have problem with normalizing whitespaces with capybara-webkit (seems capybara-webkit uses the old strategy with normalizing whitespaces as I had to silence deprecation warnings with normalizing whitespaces). Yes, you are right, capybara 3 doesn't remove browser whitespaces github.com/teamcapybara/capybara/issues/1353
– Hirurg103
Nov 21 at 7:47
No, I am not upgrading from capybara 2 to 3. I just upgraded from capybara 3.5 to 3.11. But I didn't have problem with normalizing whitespaces with capybara-webkit (seems capybara-webkit uses the old strategy with normalizing whitespaces as I had to silence deprecation warnings with normalizing whitespaces). Yes, you are right, capybara 3 doesn't remove browser whitespaces github.com/teamcapybara/capybara/issues/1353
– Hirurg103
Nov 21 at 7:47
@Hirurg103 If you were getting deprecation notices around whitespace with capybara-webkit then you weren't using the latest capybara-webkit which was actually compatible with Capybara 3.x - anyway you're going to be much better with Chrome since the JS/CSS support is up to date
– Thomas Walpole
Nov 21 at 8:12
@Hirurg103 If you were getting deprecation notices around whitespace with capybara-webkit then you weren't using the latest capybara-webkit which was actually compatible with Capybara 3.x - anyway you're going to be much better with Chrome since the JS/CSS support is up to date
– Thomas Walpole
Nov 21 at 8:12
Before moving to headless chrome I was using capybara
v3.5.0
and capybara-webkit v1.15.0
– Hirurg103
Nov 21 at 9:30
Before moving to headless chrome I was using capybara
v3.5.0
and capybara-webkit v1.15.0
– Hirurg103
Nov 21 at 9:30
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53392662%2fhow-to-ignore-extra-whitespaces-after-switching-to-headless-chrome%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown