Skip to content

Commit

Permalink
Added proper Proxy support
Browse files Browse the repository at this point in the history
Updated Firefox to support installing and uninstalling extensions
  • Loading branch information
darkfrog26 committed Aug 7, 2023
1 parent 7ec320c commit f23169a
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 7 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name := "robobrowser"
organization := "com.outr"
version := "1.6.1"
version := "1.7.0-SNAPSHOT"

val scala213: String = "2.13.11"

Expand Down
Binary file removed src/main/resources/anticaptcha-plugin_v0.63.crx
Binary file not shown.
2 changes: 1 addition & 1 deletion src/main/scala/com/outr/robobrowser/RoboBrowser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ abstract class RoboBrowser(val capabilities: Capabilities) extends AbstractEleme
object storage {
object cookies {
private implicit val ssRW: RW[SameSite] = RW.from(
r = (ss: SameSite) => ss match {
r = {
case SameSite.Normal => "normal"
case SameSite.Lax => "lax"
case SameSite.Strict => "strict"
Expand Down
21 changes: 16 additions & 5 deletions src/main/scala/com/outr/robobrowser/browser/BrowserOptions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,23 @@ trait BrowserOptions[O] {

def url(url: URL): O = withCapabilities("url" -> url.toString())

def proxy(proxy: Proxy): O = {
def proxy(ftp: Option[String] = None,
http: Option[String] = None,
no: Option[String] = None,
ssl: Option[String] = None,
socks: Option[String] = None,
socksVersion: Option[Int] = None,
socksUsername: Option[String] = None,
socksPassword: Option[String] = None): O = {
val p = new selenium.Proxy
// TODO: Support
// proxy.`type` match {
// case ProxyType.Direct => p.set
// }
ftp.foreach(p.setFtpProxy)
http.foreach(p.setHttpProxy)
no.foreach(p.setNoProxy)
ssl.foreach(p.setSslProxy)
socks.foreach(p.setSocksProxy)
socksVersion.foreach(i => p.setSocksVersion(i))
socksUsername.foreach(p.setSocksUsername)
socksPassword.foreach(p.setSocksPassword)
withCapabilities(CapabilityType.PROXY -> p)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,21 @@ import com.outr.robobrowser.RoboBrowser
import org.openqa.selenium.firefox.{FirefoxDriver, FirefoxOptions => SeleniumFirefoxOptions}

import java.io.{File, FileNotFoundException}
import java.nio.file.Path

class Firefox(options: SeleniumFirefoxOptions) extends RoboBrowser(options) {
override type Driver = FirefoxDriver

override def sessionId: String = "Firefox"

def installExtension(path: Path): String = withDriver { driver =>
driver.installExtension(path)
}

def uninstallExtension(extensionId: String): Unit = withDriver { driver =>
driver.uninstallExtension(extensionId)
}

override protected def createDriver(): FirefoxDriver = new FirefoxDriver(options)
}

Expand Down

0 comments on commit f23169a

Please sign in to comment.