{"action":"created","comment":{"url":"https://api.github.com/repos/watir/watir-webdriver/pulls/comments/27768223","id":27768223,"diff_hunk":"@@ -147,6 +147,15 @@ def wd_find_by_regexp_selector(selector, method = :find)\n         raise Error, \"internal error: unable to build WebDriver selector from #{selector.inspect}\"\n       end\n \n+      if how == :xpath && convert_regexp?\n+        rx_selector.each do |key, value|\n+          unless key == :text || key == :tag_name","path":"lib/watir-webdriver/locators/element_locator.rb","position":6,"original_position":6,"commit_id":"9ff2ec775466dc25184948680b54ef659b304a4a","original_commit_id":"9ff2ec775466dc25184948680b54ef659b304a4a","user":{"login":"p0deje","id":665846,"avatar_url":"https://avatars.githubusercontent.com/u/665846?v=3","gravatar_id":"","url":"https://api.github.com/users/p0deje","html_url":"https://github.com/p0deje","followers_url":"https://api.github.com/users/p0deje/followers","following_url":"https://api.github.com/users/p0deje/following{/other_user}","gists_url":"https://api.github.com/users/p0deje/gists{/gist_id}","starred_url":"https://api.github.com/users/p0deje/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/p0deje/subscriptions","organizations_url":"https://api.github.com/users/p0deje/orgs","repos_url":"https://api.github.com/users/p0deje/repos","events_url":"https://api.github.com/users/p0deje/events{/privacy}","received_events_url":"https://api.github.com/users/p0deje/received_events","type":"User","site_admin":false},"body":"Avoid using unless with 2 or more conditions.\r\n\r\n```ruby\r\nrx_selector.each do |key, value|\r\n  next if key == :text || key == :tag_name\r\n  # code\r\nend\r\n```\r\n","created_at":"2015-04-04T10:50:51Z","updated_at":"2015-04-04T10:50:51Z","html_url":"https://github.com/watir/watir-webdriver/pull/331#discussion_r27768223","pull_request_url":"https://api.github.com/repos/watir/watir-webdriver/pulls/331","_links":{"self":{"href":"https://api.github.com/repos/watir/watir-webdriver/pulls/comments/27768223"},"html":{"href":"https://github.com/watir/watir-webdriver/pull/331#discussion_r27768223"},"pull_request":{"href":"https://api.github.com/repos/watir/watir-webdriver/pulls/331"}}},"pull_request":{"url":"https://api.github.com/repos/watir/watir-webdriver/pulls/331","id":32604397,"html_url":"https://github.com/watir/watir-webdriver/pull/331","diff_url":"https://github.com/watir/watir-webdriver/pull/331.diff","patch_url":"https://github.com/watir/watir-webdriver/pull/331.patch","issue_url":"https://api.github.com/repos/watir/watir-webdriver/issues/331","number":331,"state":"open","locked":false,"title":"Optimize regexp selectors when using xpath","user":{"login":"marxarelli","id":239740,"avatar_url":"https://avatars.githubusercontent.com/u/239740?v=3","gravatar_id":"","url":"https://api.github.com/users/marxarelli","html_url":"https://github.com/marxarelli","followers_url":"https://api.github.com/users/marxarelli/followers","following_url":"https://api.github.com/users/marxarelli/following{/other_user}","gists_url":"https://api.github.com/users/marxarelli/gists{/gist_id}","starred_url":"https://api.github.com/users/marxarelli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marxarelli/subscriptions","organizations_url":"https://api.github.com/users/marxarelli/orgs","repos_url":"https://api.github.com/users/marxarelli/repos","events_url":"https://api.github.com/users/marxarelli/events{/privacy}","received_events_url":"https://api.github.com/users/marxarelli/received_events","type":"User","site_admin":false},"body":"Regexp selectors are highly inefficient as they require additional round\r\ntrip requests (to retrieve attribute values) for each element that\r\nmatches the simplified selector. This optimization limits the number of\r\nrequests needed by converting leading and trailing runs of literals in\r\neach regular expression to to an xpath `contains` predicate. Note that\r\nproblematic regular expressions such as case insensitive patterns and\r\nthose containing '|' are not converted.","created_at":"2015-04-03T17:53:08Z","updated_at":"2015-04-04T10:50:51Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7704126f6ca565943178f5e4f6c3236b40edb6fe","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/watir/watir-webdriver/pulls/331/commits","review_comments_url":"https://api.github.com/repos/watir/watir-webdriver/pulls/331/comments","review_comment_url":"https://api.github.com/repos/watir/watir-webdriver/pulls/comments{/number}","comments_url":"https://api.github.com/repos/watir/watir-webdriver/issues/331/comments","statuses_url":"https://api.github.com/repos/watir/watir-webdriver/statuses/9ff2ec775466dc25184948680b54ef659b304a4a","head":{"label":"marxarelli:optimize-regexp-selectors","ref":"optimize-regexp-selectors","sha":"9ff2ec775466dc25184948680b54ef659b304a4a","user":{"login":"marxarelli","id":239740,"avatar_url":"https://avatars.githubusercontent.com/u/239740?v=3","gravatar_id":"","url":"https://api.github.com/users/marxarelli","html_url":"https://github.com/marxarelli","followers_url":"https://api.github.com/users/marxarelli/followers","following_url":"https://api.github.com/users/marxarelli/following{/other_user}","gists_url":"https://api.github.com/users/marxarelli/gists{/gist_id}","starred_url":"https://api.github.com/users/marxarelli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marxarelli/subscriptions","organizations_url":"https://api.github.com/users/marxarelli/orgs","repos_url":"https://api.github.com/users/marxarelli/repos","events_url":"https://api.github.com/users/marxarelli/events{/privacy}","received_events_url":"https://api.github.com/users/marxarelli/received_events","type":"User","site_admin":false},"repo":{"id":33205914,"name":"watir-webdriver","full_name":"marxarelli/watir-webdriver","owner":{"login":"marxarelli","id":239740,"avatar_url":"https://avatars.githubusercontent.com/u/239740?v=3","gravatar_id":"","url":"https://api.github.com/users/marxarelli","html_url":"https://github.com/marxarelli","followers_url":"https://api.github.com/users/marxarelli/followers","following_url":"https://api.github.com/users/marxarelli/following{/other_user}","gists_url":"https://api.github.com/users/marxarelli/gists{/gist_id}","starred_url":"https://api.github.com/users/marxarelli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marxarelli/subscriptions","organizations_url":"https://api.github.com/users/marxarelli/orgs","repos_url":"https://api.github.com/users/marxarelli/repos","events_url":"https://api.github.com/users/marxarelli/events{/privacy}","received_events_url":"https://api.github.com/users/marxarelli/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/marxarelli/watir-webdriver","description":"Watir implementation on WebDriver","fork":true,"url":"https://api.github.com/repos/marxarelli/watir-webdriver","forks_url":"https://api.github.com/repos/marxarelli/watir-webdriver/forks","keys_url":"https://api.github.com/repos/marxarelli/watir-webdriver/keys{/key_id}","collaborators_url":"https://api.github.com/repos/marxarelli/watir-webdriver/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/marxarelli/watir-webdriver/teams","hooks_url":"https://api.github.com/repos/marxarelli/watir-webdriver/hooks","issue_events_url":"https://api.github.com/repos/marxarelli/watir-webdriver/issues/events{/number}","events_url":"https://api.github.com/repos/marxarelli/watir-webdriver/events","assignees_url":"https://api.github.com/repos/marxarelli/watir-webdriver/assignees{/user}","branches_url":"https://api.github.com/repos/marxarelli/watir-webdriver/branches{/branch}","tags_url":"https://api.github.com/repos/marxarelli/watir-webdriver/tags","blobs_url":"https://api.github.com/repos/marxarelli/watir-webdriver/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/marxarelli/watir-webdriver/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/marxarelli/watir-webdriver/git/refs{/sha}","trees_url":"https://api.github.com/repos/marxarelli/watir-webdriver/git/trees{/sha}","statuses_url":"https://api.github.com/repos/marxarelli/watir-webdriver/statuses/{sha}","languages_url":"https://api.github.com/repos/marxarelli/watir-webdriver/languages","stargazers_url":"https://api.github.com/repos/marxarelli/watir-webdriver/stargazers","contributors_url":"https://api.github.com/repos/marxarelli/watir-webdriver/contributors","subscribers_url":"https://api.github.com/repos/marxarelli/watir-webdriver/subscribers","subscription_url":"https://api.github.com/repos/marxarelli/watir-webdriver/subscription","commits_url":"https://api.github.com/repos/marxarelli/watir-webdriver/commits{/sha}","git_commits_url":"https://api.github.com/repos/marxarelli/watir-webdriver/git/commits{/sha}","comments_url":"https://api.github.com/repos/marxarelli/watir-webdriver/comments{/number}","issue_comment_url":"https://api.github.com/repos/marxarelli/watir-webdriver/issues/comments{/number}","contents_url":"https://api.github.com/repos/marxarelli/watir-webdriver/contents/{+path}","compare_url":"https://api.github.com/repos/marxarelli/watir-webdriver/compare/{base}...{head}","merges_url":"https://api.github.com/repos/marxarelli/watir-webdriver/merges","archive_url":"https://api.github.com/repos/marxarelli/watir-webdriver/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/marxarelli/watir-webdriver/downloads","issues_url":"https://api.github.com/repos/marxarelli/watir-webdriver/issues{/number}","pulls_url":"https://api.github.com/repos/marxarelli/watir-webdriver/pulls{/number}","milestones_url":"https://api.github.com/repos/marxarelli/watir-webdriver/milestones{/number}","notifications_url":"https://api.github.com/repos/marxarelli/watir-webdriver/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/marxarelli/watir-webdriver/labels{/name}","releases_url":"https://api.github.com/repos/marxarelli/watir-webdriver/releases{/id}","created_at":"2015-03-31T19:42:15Z","updated_at":"2015-04-03T17:33:02Z","pushed_at":"2015-04-03T18:17:05Z","git_url":"git://github.com/marxarelli/watir-webdriver.git","ssh_url":"git@github.com:marxarelli/watir-webdriver.git","clone_url":"https://github.com/marxarelli/watir-webdriver.git","svn_url":"https://github.com/marxarelli/watir-webdriver","homepage":"http://watirwebdriver.com","size":7492,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"watir:master","ref":"master","sha":"22ea39280d5563c21781c55f2ff93f23b8c14bb2","user":{"login":"watir","id":1331009,"avatar_url":"https://avatars.githubusercontent.com/u/1331009?v=3","gravatar_id":"","url":"https://api.github.com/users/watir","html_url":"https://github.com/watir","followers_url":"https://api.github.com/users/watir/followers","following_url":"https://api.github.com/users/watir/following{/other_user}","gists_url":"https://api.github.com/users/watir/gists{/gist_id}","starred_url":"https://api.github.com/users/watir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/watir/subscriptions","organizations_url":"https://api.github.com/users/watir/orgs","repos_url":"https://api.github.com/users/watir/repos","events_url":"https://api.github.com/users/watir/events{/privacy}","received_events_url":"https://api.github.com/users/watir/received_events","type":"Organization","site_admin":false},"repo":{"id":366200,"name":"watir-webdriver","full_name":"watir/watir-webdriver","owner":{"login":"watir","id":1331009,"avatar_url":"https://avatars.githubusercontent.com/u/1331009?v=3","gravatar_id":"","url":"https://api.github.com/users/watir","html_url":"https://github.com/watir","followers_url":"https://api.github.com/users/watir/followers","following_url":"https://api.github.com/users/watir/following{/other_user}","gists_url":"https://api.github.com/users/watir/gists{/gist_id}","starred_url":"https://api.github.com/users/watir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/watir/subscriptions","organizations_url":"https://api.github.com/users/watir/orgs","repos_url":"https://api.github.com/users/watir/repos","events_url":"https://api.github.com/users/watir/events{/privacy}","received_events_url":"https://api.github.com/users/watir/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/watir/watir-webdriver","description":"Watir implementation on WebDriver","fork":false,"url":"https://api.github.com/repos/watir/watir-webdriver","forks_url":"https://api.github.com/repos/watir/watir-webdriver/forks","keys_url":"https://api.github.com/repos/watir/watir-webdriver/keys{/key_id}","collaborators_url":"https://api.github.com/repos/watir/watir-webdriver/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/watir/watir-webdriver/teams","hooks_url":"https://api.github.com/repos/watir/watir-webdriver/hooks","issue_events_url":"https://api.github.com/repos/watir/watir-webdriver/issues/events{/number}","events_url":"https://api.github.com/repos/watir/watir-webdriver/events","assignees_url":"https://api.github.com/repos/watir/watir-webdriver/assignees{/user}","branches_url":"https://api.github.com/repos/watir/watir-webdriver/branches{/branch}","tags_url":"https://api.github.com/repos/watir/watir-webdriver/tags","blobs_url":"https://api.github.com/repos/watir/watir-webdriver/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/watir/watir-webdriver/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/watir/watir-webdriver/git/refs{/sha}","trees_url":"https://api.github.com/repos/watir/watir-webdriver/git/trees{/sha}","statuses_url":"https://api.github.com/repos/watir/watir-webdriver/statuses/{sha}","languages_url":"https://api.github.com/repos/watir/watir-webdriver/languages","stargazers_url":"https://api.github.com/repos/watir/watir-webdriver/stargazers","contributors_url":"https://api.github.com/repos/watir/watir-webdriver/contributors","subscribers_url":"https://api.github.com/repos/watir/watir-webdriver/subscribers","subscription_url":"https://api.github.com/repos/watir/watir-webdriver/subscription","commits_url":"https://api.github.com/repos/watir/watir-webdriver/commits{/sha}","git_commits_url":"https://api.github.com/repos/watir/watir-webdriver/git/commits{/sha}","comments_url":"https://api.github.com/repos/watir/watir-webdriver/comments{/number}","issue_comment_url":"https://api.github.com/repos/watir/watir-webdriver/issues/comments{/number}","contents_url":"https://api.github.com/repos/watir/watir-webdriver/contents/{+path}","compare_url":"https://api.github.com/repos/watir/watir-webdriver/compare/{base}...{head}","merges_url":"https://api.github.com/repos/watir/watir-webdriver/merges","archive_url":"https://api.github.com/repos/watir/watir-webdriver/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/watir/watir-webdriver/downloads","issues_url":"https://api.github.com/repos/watir/watir-webdriver/issues{/number}","pulls_url":"https://api.github.com/repos/watir/watir-webdriver/pulls{/number}","milestones_url":"https://api.github.com/repos/watir/watir-webdriver/milestones{/number}","notifications_url":"https://api.github.com/repos/watir/watir-webdriver/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/watir/watir-webdriver/labels{/name}","releases_url":"https://api.github.com/repos/watir/watir-webdriver/releases{/id}","created_at":"2009-11-09T11:40:46Z","updated_at":"2015-04-02T23:31:50Z","pushed_at":"2015-04-03T18:17:05Z","git_url":"git://github.com/watir/watir-webdriver.git","ssh_url":"git@github.com:watir/watir-webdriver.git","clone_url":"https://github.com/watir/watir-webdriver.git","svn_url":"https://github.com/watir/watir-webdriver","homepage":"http://watirwebdriver.com","size":7492,"stargazers_count":496,"watchers_count":496,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":109,"mirror_url":null,"open_issues_count":11,"forks":109,"open_issues":11,"watchers":496,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/watir/watir-webdriver/pulls/331"},"html":{"href":"https://github.com/watir/watir-webdriver/pull/331"},"issue":{"href":"https://api.github.com/repos/watir/watir-webdriver/issues/331"},"comments":{"href":"https://api.github.com/repos/watir/watir-webdriver/issues/331/comments"},"review_comments":{"href":"https://api.github.com/repos/watir/watir-webdriver/pulls/331/comments"},"review_comment":{"href":"https://api.github.com/repos/watir/watir-webdriver/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/watir/watir-webdriver/pulls/331/commits"},"statuses":{"href":"https://api.github.com/repos/watir/watir-webdriver/statuses/9ff2ec775466dc25184948680b54ef659b304a4a"}}}}