下午好!
要在Firefox浏览器中通过Selify检查getbootstrap.com上的css元素的字体大小,我使用以下脚本:
# !/usr/bin/env perl
use strict;
use warnings;
use Test::More;
use Selenium::Firefox;
my $url = 'http://getbootstrap.com';
my $driver = Selenium::Firefox->new();
$driver->get($url);
my $elt = $driver->find_element(
'h1.mb-3.fw-semibold', 'css');
is $elt->get_css_attribute('font-size'), '72px',
'Masthead font size is unchanged';
$driver->quit();
done_testing;
当脚本运行时,测试失败:
❯ ./selenium_properties_css_attribute.pl
not ok 1 - Masthead font size is unchanged
# Failed test 'Masthead font size is unchanged'
# at ./selenium_properties_css_attribute.pl line 12.
# got: '64px'
# expected: '72px'
1..1
Killing Driver PID 4132 listening on port 45685...
# Looks like you failed 1 test of 1.
你能告诉我为什么考试不及格吗?在Firefox浏览器的getbootstrap.com页面上,在元素h1.mb-3.fw-Semiold的Computed选项卡中,我们看到字体大小为72px,但当我们运行测试时,我们得到64px。为什么?
显示字体大小的截图为72px:
1条答案
按热度按时间11dmarpk1#
标题的css包括:
因此,字体大小取决于视区的宽度。您没有显式控制Firefox浏览器视口中的宽度。