DocsyテーマはHugo Moduleとして取り込まれているため、
hugo serverを実行する際にHugoがこれを解決するにはGoが必要です。
go.modに記載された最小バージョンを満たす任意のバージョンをインストールしてください。
依存関係: Node.js(省略可、本番用CSSパイプライン向け)
hugo serverでサイトをプレビューするだけであれば、Node.jsは不要です。開発モードでは
Docsyが PostCSS の処理をスキップします。ローカルのビルドを、build-site.sh内の
hugo --minifyが実行する本番用CSSパイプライン(autoprefixer/PostCSS)に合わせたい場合にのみ、
Node.js(現行の任意のリリース)が必要です。その場合は、先に
website_and_docsでnpm installを実行してください。
リポジトリにはサイトとドキュメントが含まれています。 変更を加える前に、submoduleを初期化し、必要な依存関係をインストールしてください(以下のコマンドを参照)。サイトに変更を加えるには、website_and_docs ディレクトリで作業してください。変更のライブプレビューを確認するには、サイトのルートディレクトリで hugo serverを実行してください。
% git submodule update --init --recursive
% cd website_and_docs
% hugo server
Fixes #Nを含めてください。ここでは N がこのコミットで修正したイシュー番号です(存在する場合)。
適切なコミットメッセージは次のようになります:
explain commit normatively in one line
Body of commit message is a few lines of text, explaining things
in more detail, possibly giving some background about the issue
being fixed, etc.
The body of the commit message can be several paragraphs, and
please do proper word-wrap and keep columns shorter than about
72 characters or so. That way `git log` will show things
nicely even when it is indented.
Fixes #141
How to update the Selenium site pages outside of the documentation
The Selenium site is built with Hugo and the Docsy theme.
The site root is the website_and_docs directory. Follow the
contribution mechanics to set up your
environment and preview your changes with hugo server.
Where things live
What
Where
Home page
content/_index.<language>.html
Top level pages (downloads, support, projects, sponsors, etc.)
Some pages have most of their content in the template instead of the Markdown file.
For example, the content of the Downloads page lives in layouts/downloads/list.html.
Markdown versions of documentation pages
Every documentation page is also published as Markdown, at index.md beside its index.html
(for example, /documentation/webdriver/waits/index.md), for AI agents and other tools that read
the site. Each shortcode used in the documentation needs a Markdown template next to its HTML one,
named <shortcode>.markdown.md (the markdown part keeps Hugo from also using it for HTML).
If you add a shortcode to the documentation, add its Markdown template too, and check the page’s
index.md in your preview. build-site.sh fails when a page’s index.md has HTML from a shortcode
that has no Markdown template.
Blog posts
Add a new Markdown file under content/blog/<year>/. Copy the front matter of a recent post
and update the title, linkTitle, date, tags, categories, author, and description.
To use a custom image when the post is shared on social media, add it under
static/images/blog/<year>/ and reference it in the images front matter key.
Translations
The home page and the documentation are translated. Most of the other site pages, including the
blog, are only available in English. When you change text on a translated page, see
Translations in the style guide.
Checking your changes
Site changes are not covered by tests, so preview every page you changed with hugo server.
Every pull request gets a Netlify deploy preview; check it before asking for a review.
2.2 - Contributing to the Selenium documentation
How the Selenium documentation is organized and how to change it
The documentation lives in website_and_docs/content/documentation. Follow the
contribution mechanics to set up your
environment and preview your changes with hugo server.
Structure
Each directory is a section of the documentation, and its _index.<language>.md file is the
section landing page. Each page has one file per language:
<page>.en.md
<page>.ja.md
<page>.pt-br.md
<page>.zh-cn.md
When you add a page, add a file for each language. If you are not translating the content,
copy the English text into the other language files.
Each page starts with front matter like this:
---title:"Sentence capitalization title that describes the page"linkTitle:"Short Title"weight:4description:> One sentence summary of the page.---
weight defines the order of the page in the navigation.
See Capitalization of titles for the
title and linkTitle conventions.
Writing
Keep the prose language independent. Anything specific to a language binding goes inside
code tabs.
Follow the style guide for line length, alerts, and code tabs.
Mark missing content with the alerts described in the
style guide, so others know where help is needed.
Link to other documentation pages with the ref shortcode, e.g.,
[Waits]({{< ref "waits.md" >}}), so broken links fail the build.
Code in the documentation
Code shown in the documentation must come from runnable examples. See
Code examples for how to create them and render them on a page.
How to create runnable code examples and render them in the documentation
We want to be able to run all of our code examples in the CI to ensure that people can copy, paste and
execute everything on the site. So the code lives in the
examples directory,
and the documentation renders it from there.
Each example gets its own test. This keeps the example focused and lets the
documentation point to exactly the lines that matter.
Use the Selenium test pages. Examples need a web page to work against. Use the pages available at
https://www.selenium.dev/selenium/web/ instead of third party sites, which can change or go offline
and break the examples.
Assert the outcome. Each test should have an assertion that verifies the code works as intended,
so that a broken example fails the CI.
Keep the shown code free of test noise. Write the test so that the lines shown in the documentation
are only the Selenium code the reader needs. Assertions and test setup are not shown, unless the
assertion is the clearest way to show the result of the command (e.g., the value returned by a getter).
Run the tests. Run the tests for each language you changed locally, and make sure they pass in the CI.
Each language directory in the
examples directory
has a README with the instructions to run its tests.
These are code examples that are written directly in the Markdown file. Everything from
Creating examples applies: move the code into a test, then render it with
gh-codeblock as described below.
Rendering examples
Once the code is in its own test, it needs to be referenced in the Markdown file with the gh-codeblock
shortcode. For example, the tab in Ruby would look like this:
See Reference GitHub Examples in the style guide for
the complete tabpane syntax. Keep in mind the following:
Show only the relevant lines. The line numbers at the end of the path (#L8-L9) select the lines
that are displayed. Use a single line (#L8) or a range of lines (#L8-L9). Readers can click
“View Complete Code” or “View on GitHub” to see the full test.
One range per code block. A gh-codeblock displays one continuous range of lines.
If the lines you want to show are not next to each other, reorganize the test so they are,
or use one gh-codeblock for each range.
Use text=true. By default, the tabs get formatted for code, so to use markdown or other shortcode
statements (like gh-codeblock) it needs to be declared as text.
For most examples, the tabpane declares the text=true, but if some of the tabs have code examples,
the tabpane cannot specify it, and it must be specified in the tabs that do not need automatic code formatting.
Do not indent the gh-codeblock line. An indented line is rendered as a Markdown code block
instead of running the shortcode.
Keep line numbers up to date. When you add, remove or move lines in an example file, every
gh-codeblock that points to that file below the change needs new line numbers. Search
website_and_docs/content for the file path, and check all languages of the page.
Add the example to all translations. Update the gh-codeblock references in the .ja.md, .pt-br.md
and .zh-cn.md files of the page too.
このドキュメントでは、短くするべき linkTitle にはタイトルケースを使用し、
より長く説明的にできる title には文頭のみ大文字にする形式を使用します。
例えば、linkTitle が Special Heading の場合、title は
The importance of a special heading in documentation のようになります。
This is a work in progress. Feel free to add things you know or remember.
How did the Automation Atoms come about?
On 2012-04-04, jimevans asked on the #selenium IRC channel:
“What I wanted to ask you about was the history of the automation atoms. I seem to remember them springing fully formed, as if from the head of Zeus, and I’m sure that wasn’t the case. Can you refresh my memory as to how the concept happened?”
simonstewart then proceeded to tell us a nice little story:
Sure. Are we sitting comfortably? Then I’ll begin. (Brit joke, there)
Imagine wavy lines as the screen dissolves and we’re transported back to when selenium and webdriver were different projects. Before the projects merged, there was an awful lot of congruent code in webdriver. Congruent, but not shared. The Firefox driver was in JS. The IE driver was mostly C++. The Chrome driver was mostly JS, but different JS from the Firefox driver. And HtmlUnit was unique.
We then added Selenium Core to the mix. Yet more JS that did basically the same thing.
Within Google, I was becoming the TL of the browser automation team. And was corralling a framework of our own into the mix. Which was written in JS, and had once been based on Core before it span off on its own path.
So: multiple codebases, lots of JS doing more or less the same thing. And loads of bugs. Weird mismatches of behaviour in edge-cases.
*shudder*
So I had a bit of a think. (Dangerous, I know) The idea was to extract the “best of breed” code from all three frameworks (Core, WebDriver and the Google tool). Break them down into code that could be shared. “The smallest, indivisible unit of browser automation” .
Or “atoms” for short.
These could be used as the basis the everything. Consistent behaviour between browsers. and apis. The other important point was that the JS code in webdriver and core was grown organically. Which is a polite way of saying “I’d rather never edit it again”. Which is a polite way of saying that it was of dubious quality . In places.
So: high quality was important. And I wanted the code broken up into modules. Because editing a 10k LOC file isn’t a bright idea.
Within Google we had a library called Closure. Which not only allowed modularization, but “denormalization” of modules into a single file via compilation. And I knew it was being open sourced. So we started building the library in the google codebase. (Where we had access to the unreleased library, code review tools and our amazing testing infrastructure). Using Closure Library.
“dom.js” was probably the first file I wrote. (We can check). Greg Dennis and Jason Leyba joined in the fun. And the atoms have been growing ever since.
Technically, we should be calling anything outside of “javascript/atoms” molecules. But then we can’t say that we have atomic drivers. and use imagery from the 50s to describe them.
*sigh*
jimevans replied: “molecular drivers?”
And simonstewart finished with:
Indeed :) The idea is that the atoms are the lowest level. And we compose the atoms to conform to the WebDriver or RC apis in “javascript/{selenium,webdriver}-atoms” respecitively. And then suck those in as necessary.
A Story of Crazy-Fun
Simon Stewart :
So, let’s go back to the very beginning of the project
When it was me, on my own (the webdriver project, that is, not selenium itself) I knew that I wanted to cover multiple different languages, and so wanted a build tool that could work with all of them That is, that didn't have a built in preference for one that made working with other languages painful ant is java biased. As is maven. nant and msbuild are .net biased rake, otoh, supports nothing very well But, and this is key, any valid rake script is also a valid ruby program It's possible to extend rake to build anything So: rake it was The initial rake file was pretty small and manageable But as the project grew, so did the Rakefile Until there was only person who could deal with it (me), and even then it was pretty shaky So, rather than have a project that couldn't be built, I extracted some helper methods to do some of the heavy lifting Which made the Rakefile comprehensible again But they project kept. getting. bigger And the Rakefile got harder and harder to grok At the time, I was working at Google, who have a wonderful build system Google's system is declarative and works across multiple different languages consistently And, most important, it breaks up the build from a single file into little fragments I asked the OSS chaps at Google if it was okay to open source the build grammar, and they gave it the green light So we layered that build grammar into the selenium codebase With one minor change (we handle dictionary args) But that grammar sits on top of rake still, after all this time And there's a problem And that's that rake is single threaded So our builds are constrained to run serially We could use "multitask" types to improve things, but when I've tried that things got very messy, very fast So, our next hurdle is that crazyfun.rb is slow: we need to go faster Which implies a rewrite of crazyfun I'm most comfortable in java So, I've spiked a new version in java that handles the java and js compilation It's significantly faster But, and this is also important, it's a spike The code was designed to be disposable. Now that things have been proved out, I'd really like to do a clean implementation But I'm torn Do I "finish" the new, very fast crazyfun java enough to replace the ruby version?
A story of driver executables
jimevans noob_einsteinsfo: alright, story time, then. are we sitting comfortably? then we'll begin. noob_einsteinsfo: back when i first started working on the project (circa 2010), the drivers for all of the browsers were built and maintained by the project. at the time, that meant IE, firefox, and chrome. all of those drivers were packaged as part of the selenium standalone server, and were also packaged in with the various language bindings. this was a conscious decision, so that if one were running locally, there would be no need for the java runtime on the machine just to automate a given browser. there were two factors that led to the development of browser drivers as separate executables. as a quick aside, remember that the webdriver philosophy is to automate the browser using the "best-fit" mechanism for that particular browser. for IE, that means using the COM interfaces; for firefox at the time, that meant using a browser extension; for chrome, it also meant a browser extension. so that meant that the IE driver was developed as a DLL in C++ that was loaded by the language bindings, and communicated with via whatever native-code mechanism was provided by the language (JNI for java, P/Invoke for .NET, ctypes for python, etc.). it also meant that the firefox driver was developed as a browser extension that was packaged inside the various language bindings, and extracted, and used in a profile in firefox. as i said, the IE driver was implemented as a DLL, loaded and communicated with using different mechanisms for different language bindings. the problem is that each of those language-specific mechanisms had different load/unload semantics. ruby, for example, would never call the windows FreeLibrary API after loading the DLL into memory, making multiple instances really challenging. *process* semantics, however, as in, starting, stopping, and managing the lifetime of a process on the OS, whatever the OS, are remarkably similar across all languages. so when the IE driver rewrite was completed in 2010, the development team (me) decided to make it a separate executable, so that the load/unload semantics could be consistent no matter what language bindings one was using. concurrently with this, the chromium team made the decision to follow opera's lead and provide a driver implementation for chrome. an implementation that they would develop, enhance, and maintain going forward, relieving the selenium project of the burden of maintaining a chrome driver.
XgizmoX and that driver is part of the browser?
jimevans XgizmoX: not really, but i believe there may be some smarts built into chrome itself that knows when it's being automated via chromedriver. one of the googlers would be a better person to ask about that. anyway, knowing the different in shared library (.dll/.so/.dynlib) loading semantics, the chromium team (with my encouragement) decided to release their chromedriver implementation as a separate executable. fast-forward a couple of years, and you begin to see the effort to make webdriver a w3c standard. a working group with the w3c created a specification (still in progress, but getting close to finished with the first version), which codified the behavior of webdriver, and how a browser should react to its methods. furthermore, it standardized the protocol used to communicate between language bindings and a driver for a particular browser. i can't emphasize how important and groundbreaking this was. because the w3c and the webdriver working group within it are made up of representatives from the browser vendors themselves, it ensures that the solution will be supported directly by the browser vendors. mozilla created their webdriver implementation (geckodriver) for firefox. the most efficient mechanism for distribution of that browser driver, while maintaining the proper semantics for the language bindings, was to ship as a separate executable. note, this is a gross oversimplification of the geckodriver architecture; the actual executable acts as a relatively thin shim, translating from the wire protocol of the spec to their internal marionette protocol but the point still stands. anyway, the landscape is currently evolving regarding browser-vendor-provided driver implementation. microsoft has one for edge, apple has one for safari (10 and above), the chromium team (largely staffed by googlers) has one for chrome, and now mozilla has one for firefox. given the limited utility of the legacy firefox driver going forward, breaking it out into a separate executable would be wasted effort. this is particularly so, since all of the communication bits that are normally handled by the executable (listening for and responding to http requests from the language bindings) are handled entirely by the browser extension. \ there's literally no need for the legacy firefox driver to be a separate executable. moreover, making it independent of a language runtime would be a significant portion of work (because a .NET shop might reasonably balk at being required to install, say, the java runtime just to automate firefox) so historically speaking, noob-einsteinsfo, that's the general reason for why separate executables have become the norm, and why that paradigm wasn't extended to include the legacy firefox driver. does that make sense? okay. now. about geckodriver. the tale of geckodriver is intimately bound with the status of the aforementioned w3c webdriver spec. level 1 of the specification is mostly done, though it took a number of years of effort to get there. it took a large effort from some very smart people (AutomatedTester among them) to mold the initial documentation of what the webdriver open source software (OSS) project did into proper specification language that could be interpreted and turned into actionable stuff by a browser vendor or other implementer. when beginning the geckodriver (nee marionette) project, mozilla decided to base their implementation on the spec, and only the spec, not following the OSS implementation. this created something of a chicken-and-egg problem, in that while the spec language wasn't completed, it couldn't be implemented. it's only been in the last six months or so that the language concerning the advanced user interactions api (the Actions class in java and .NET) has been made robust enough to actually implement. accordingly, that's the single biggest missing chunk of functionality in geckodriver at present. it wasn't implementable via the spec, so it hasn't been implemented. i do know that it's a very high priority for AutomatedTester and his team to get that implementation done and available. as for why geckodriver is mandatory, and the default implementation for automating firefox in 3.x, that also comes down to some decisions made by mozilla.
TheSchaf so i guess there is no other choice than to use the old FF as long as required features are missing WhereIsMySpoon TheSchaf: if you need those features, yes or use another browser TheSchaf well, moveTo and sendKeys should be pretty basic :p
jimevans TheSchaf: element.sendKeys works just fine. it's Actions.sendKeys that would be broken. in firefox version fortysomething (i misremember the exact version), there was a feature added that blocked browser extensions that hadn't been signed by the mozilla security team. remember that the legacy firefox driver was built as a browser extension? well, with that feature of the browser enabled, the legacy driver couldn't be loaded by the browser. now, for several versions of firefox, it was possible to disable this feature of the browser, and allow unsigned extensions to continue to be loaded. and selenium did this, by virtue of the settings used in the anonymous profile the bindings created when launching firefox. until firefox 48, at which point, it was no longer possible to disable loading of unsigned extensions. at that point, geckodriver was the only way forward for that. now, two more slight points, then i'll be done with story time. first, by nature of what the legacy driver extension does, it's not possible to get it to pass the certification process of the mozilla security team. we asked, were denied, and were told it wouldn't happen ever, full stop. and that's perfectly reasonable, since what that extension does is a security hole big enough to drive a whole fleet of lorries through. second, it turns out there may, in fact, be a way to privately sign the legacy extension so that it can be loaded and used privately by versions of firefox 48 and higher. that's still a less-than-ideal approach, because there's no way that our merry band of open source developers can know how to automate firefox better than the development teams at mozilla, who create the browser in the first place. i totally get the frustration that geckodriver doesn't have the full feature parity of the legacy implementation, especially when it feels like one is being forced to move to it. raging at the selenium project about that decision is directing one's ire in entirely the wrong direction. however, before going off and saying horrible things about mozilla's decisions, do know that mozilla has several people who are constantly engaged in the project, a few of them right here in this very channel (AutomatedTester, davehunt, to name two). i'm sure i've glossed over or mischaracterized some of the historical details of these things, and i'm happy to be corrected. i'm old, after all, and the memory isn't what it used to be. but that, my friends, is the (not so very) short history of why we have separate executables for drivers, and why geckodriver is the way forward, and why a move to it was necessary when the move was made even though some functionality was lacking.
jimevans feels like he's become an unofficial historian of the webdriver project