adspower-client 1.0.6 → 1.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 65fd0729b150916bca53b79d7170a4fd1a94743931b4d7b0f9b2cf35e1f6c494
4
- data.tar.gz: cb714f0f424bda981b6778de80e00dfce84b318fe091d2af8e91b5861aa24996
3
+ metadata.gz: d0b0359e814e6da477e31d71c4233e45a3fa390bb5b0d7261cb653ca74171c97
4
+ data.tar.gz: c3f25e5ea1321af5642563748f69cd76707479dfb8963791c0936755cefcc1f6
5
5
  SHA512:
6
- metadata.gz: a813f08b9ea6c25ecbffd99b8b8ecce3f1d7d2519449bc3c47d122bf8c2569741baddf062ac8020c38b666f16c81ebeaaafdc655a0a974e05db7a3707fdec076
7
- data.tar.gz: fa6b9980e22faa8be0e21572d46beb0bef54198e96f1feae5399de06497e7226bf917ed74a6de8201c725c3c20115045bfbb785fd03918fb68d1a84429cf89b9
6
+ metadata.gz: b8e05b735de4606502fafbba815d06d1e15ab2126d0563f1fb772af0ccdbb0228aa7ef95f3b86cf91656b5dcfe4729390b27ffcb8d52ed996995734c2db43871
7
+ data.tar.gz: 866efa20033fdeddec050e1d81ab957d06238ce55d44a450311b2afe79c981528e8131f6d0d3209bf419ec7f8b86dcc7d0467bff466ce2d6cad63f61fff8dd75
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'adspower-client'
3
- s.version = '1.0.6'
4
- s.date = '2024-01-14'
3
+ s.version = '1.0.8'
4
+ s.date = '2024-02-07'
5
5
  s.summary = "Ruby library for operating AdsPower API."
6
6
  s.description = "Ruby library for operating AdsPower API."
7
7
  s.authors = ["Leandro Daniel Sardi"]
@@ -9,7 +9,10 @@ class AdsPowerClient
9
9
  # reference: https://localapi-doc-en.adspower.com/
10
10
  # reference: https://localapi-doc-en.adspower.com/docs/Rdw7Iu
11
11
  attr_accessor :key, :adspower_listener, :adspower_default_browser_version
12
- # attr_accessor :profiles_created
12
+
13
+ # control over the drivers created, in order to don't create the same driver twice and don't generate memory leaks.
14
+ # reference: https://github.com/leandrosardi/adspower-client/issues/4
15
+ @@drivers = {}
13
16
 
14
17
  def initialize(h={})
15
18
  self.key = h[:key] # mandatory
@@ -100,6 +103,12 @@ class AdsPowerClient
100
103
  # reference: https://localapi-doc-en.adspower.com/docs/DXam94
101
104
  #
102
105
  def stop(id)
106
+ # if the profile is running with driver, kill chromedriver
107
+ if @@drivers[id] && self.check(id)
108
+ @@drivers[id].quit
109
+ @@drivers[id] = nil
110
+ end
111
+
103
112
  uri = URI.parse("#{self.adspower_listener}/api/v1/browser/stop?user_id=#{id}")
104
113
  res = Net::HTTP.get(uri)
105
114
  # show respose body
@@ -128,7 +137,11 @@ class AdsPowerClient
128
137
  #
129
138
  def driver(id, headless=false)
130
139
  ret = self.start(id, headless)
140
+ old = @@drivers[id]
131
141
 
142
+ # si este driver sigue activo, lo devuelvo
143
+ return old if old && self.check(id)
144
+
132
145
  # Attach test execution to the existing browser
133
146
  # reference: https://zhiminzhan.medium.com/my-innovative-solution-to-test-automation-attach-test-execution-to-the-existing-browser-b90cda3b7d4a
134
147
  url = ret['data']['ws']['selenium']
@@ -139,6 +152,9 @@ class AdsPowerClient
139
152
  # reference: https://localapi-doc-en.adspower.com/docs/K4IsTq
140
153
  driver = Selenium::WebDriver.for(:chrome, :options=>opts)
141
154
 
155
+ # save the driver
156
+ @@drivers[id] = driver
157
+
142
158
  # return
143
159
  driver
144
160
  end # def driver
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adspower-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leandro Daniel Sardi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-14 00:00:00.000000000 Z
11
+ date: 2024-02-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: uri